Accessing an External File or Device in UNIX Environments

Specifying a Pathname or a Fileref

To access an external file or device, you need to specify its pathname or fileref in the appropriate SAS statements:
FILE
specifies the current output file for PUT statements.
%INCLUDE
includes a file that contains SAS source statements that are executed when you submit a program from the Program Editor.
Tip
If you use %INCLUDE, the line limit is 6000 bytes.
INFILE
identifies an external file that you want to read with an INPUT statement.
In the SAS statement, refer to the file or device in one of two ways:
  • Specify the pathnames for the external files. For more information, see Specifying Pathnames in UNIX Environments.
  • Assign a fileref to a device, one or more files, or a directory, and use the fileref when you want to refer to the file, directory, or device.
    In most cases, you will want to use a fileref.

What Is a Fileref?

A fileref is nickname that you assign to a file or device. You assign the fileref once, and then use it as needed. Filerefs are especially useful under the following conditions:
  • The pathname is long and has to be specified several times within a program.
  • The pathname might change. If the pathname changes, you need to change only the statement that assigns the fileref, not every reference to the file.
You can assign filerefs in the File Shortcuts window of the Explorer, with the FILENAME statement, with the FILENAME function, or by defining the fileref as an environment variable.
Note: For a complete description of the FILENAME statement and the FILENAME function, see FILENAME Statement in SAS Statements: Reference and FILENAME Function in SAS Functions and CALL Routines: Reference.