Assigns or deassigns a fileref to an external file, directory, or output device.
Category: | External Files |
See: | FILENAME Function: Windows in SAS Companion for Windows |
FILENAME Function: UNIX in SAS Companion for UNIX Environments | |
FILENAME Function: z/OS in SAS Companion for z/OS |
specifies the fileref to assign to the external file. In a DATA step, fileref can be a character expression, a string enclosed in quotation marks that specifies the fileref, or a DATA step variable whose value contains the fileref. In a macro (for example, in the %SYSFUNC function), fileref is the name of a macro variable (without an ampersand) whose value contains the fileref to assign to the external file.
Requirement | If fileref is a DATA step variable, its length must be no longer than eight characters. |
Tip | If a fileref is a DATA step character variable with a blank value and a maximum length of eight characters, or if a macro variable named in fileref has a null value, then a fileref is generated and assigned to the character variable or macro variable, respectively. |
is a character constant, variable, or expression that specifies the external file. Specifying a blank file-name deassigns a fileref that was assigned previously.
is a character constant, variable, or expression that specifies the type of device or the access method that is used if the fileref points to an input or output device or location that is not a physical file:
specifies that the device is a disk drive.
Alias | BASE |
Tip | When you assign a fileref to a file on disk, you are not required to specify DISK. |
specifies that the output to the file is discarded.
Tip | Specifying DUMMY can be useful for testing. |
indicates that the output device type is a graphics device that will be receiving graphics data.
specifies an unnamed pipe.
Note | Some operating environments do not support pipes. |
specifies an unbuffered graphics output device.
specifies a printer or printer spool file.
specifies a tape drive.
creates a temporary file that exists only as long as the filename is assigned. The temporary file can be accessed only through the logical name and is available only while the logical name exists.
Restriction | Do not specify a physical pathname. If you do, SAS returns an error. |
Tip | Files that are manipulated by the TEMP device can have the same attributes and behave identically to DISK files |
specifies the user's personal computer.
specifies a Universal Printing printer definition name.
Operating environment | The FILENAME function also supports operating environment-specific devices. For more information, see the SAS documentation for your operating environment. |
specifies host-specific details such as file attributes and processing attributes. For more information, see the SAS documentation for your operating environment.
specifies the fileref that was assigned to the directory or partitioned data set in which the external file resides.
%let filrf=myfile;
%let rc=%sysfunc(filename(filrf, physical-filename));
%if &rc ne 0 %then
%put %sysfunc(sysmsg());
%let rc=%sysfunc(filename(filrf));
%let rc=%sysfunc(filename(fname, physical-filename)); %if &rc %then %put %sysfunc(sysmsg()); %else %do; more macro statements %end;
%let filrf=mypipe; %let rc=%sysfunc(filename(filrf, %str(ls /u/myid), pipe));