Filerefs Assigned by SAS in UNIX Environments

Filerefs for Standard Input, Standard Output, and Standard Error

Often a command's arguments or options tell the command what to use for input and output, but in case they do not, the shell supplies you with three standard files: one for input (standard input), one for output (standard output), and one for error messages (standard error). By default, these files are all associated with your terminal: standard input with your keyboard, and both standard output and standard error with your terminal's display. When you invoke SAS, it assigns a fileref to each file that it opens, including the three standard files. SAS assigns the filerefs Stdin, Stdout, and Stderr to standard input, standard output, and standard error, respectively.

File Descriptors

What Is a File Descriptor?

Each file has an internal file descriptor assigned to it. By default, 0 is the file descriptor for standard input, 1 is the file descriptor for standard output, and 2 is the file descriptor for standard error. As other files are opened, they get other file descriptors. In the Bourne shell and in the Korn shell, you can specify that data be written to or be read from a file using the file descriptor as described in File Descriptors in the Bourne and Korn Shells.

File Descriptors in the Bourne and Korn Shells

If you are using the Bourne shell or the Korn shell, SAS assigns filerefs of the following form to files that have a file descriptor (see Filerefs Assigned by SAS in UNIX Environments) larger than 2.
FILDESnumber
number is a two-digit representation of the file descriptor. You can use these filerefs in your SAS applications.
For example, if you invoke SAS with the following command, then the operating environment opens the file sales_data and assigns file descriptor 4 to it:
sas salespgm 4< sales_data
SAS assigns the fileref FILDES04 to the file and executes the application salespgm. When the application reads input from FILDES04, it reads the file sales_data. Using file descriptors as filerefs enables you to use the same application to process data from different files without changing the application to refer to each file. In the command that you use to invoke the application, you assign the appropriate file descriptor to the file to be processed.