Language Reference

FILE Statement

opens or points to an external file

FILE file-name <RECFM=N> <LRECL=operand>;

The inputs to the FILE statement are as follows:


file-name
is a name (for defined filenames), a quoted literal, or an expression in parentheses (for pathnames).

RECFM=N
specifies that the file is to be written as a pure binary file without record-separator characters.

LRECL=operand
specifies the record length of the output file. The default record length is 512.

You can use the FILE statement to open a file for output, or if the file is already open, to make it the current output file so that subsequent PUT statements write to it. The FILE statement is similar in syntax and operation to the INFILE statement. The FILE statement is described in detail in Chapter 7.

The file-name is either a predefined filename or a quoted string or character expression in parentheses referring to the pathname. There are two ways to refer to an input or output file: by a pathname and by a filename. The pathname is the name as known to the operating system. The filename is a SAS reference to the file established directly through a connection made with the FILENAME statement. You can specify a file in either way in the FILE and INFILE statements. To specify a filename as the operand, just give the name. The name must be one already connected to a pathname by a previously issued FILENAME statement. There are, however, two special filenames that are recognized by IML: LOG and PRINT. These refer to the standard output streams for all SAS sessions. To specify a pathname, put it in quotes or specify an expression yielding the pathname in parentheses.

When the pathname is specified, there is a limit of 64 characters to the operand.

Note that RECFM=U is equivalent to RECFM=N. If an output file is subsequently read by a SAS DATA step, RECFM=N must be specified in the DATA step to guarantee that the file is read properly.

Following are several valid uses of FILE statement:

  
    file "student.dat";           /* by literal pathname   */ 
  
    filename out "student.dat";   /* specify filename OUT  */ 
    file out;                     /* refer to by filename  */ 
  
    file print;                   /* standard print output */ 
    file log;                     /* output to log         */ 
  
    file "student.dat" recfm=n;   /* for a binary file     */
 

Previous Page | Next Page | Top of Page