Chapter Contents

Previous

Next
SAS Companion for UNIX Environments

Filerefs Assigned by the SAS System

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 the SAS System, 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.

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, the SAS System assigns filerefs of the following form to files that have a file descriptor (see Filerefs Assigned by the SAS System) 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 simply assign the appropriate file descriptor to the file to be processed.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.