Language Reference
FILE Statement
FILE filename <RECFM=N> <LRECL=operand> ;
This statement is supported only by the IML procedure.
The FILE statement opens an external file for output.
The arguments to the FILE statement are as follows:
- filename
is a name (for defined file names), a quoted literal, or an expression in parentheses (for path names).
- RECFM=N
specifies that the file 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 filename argument is either a predefined file name or a quoted string or character expression in parentheses referring to the path name. You can refer to an input or output file two ways: by a path name or by a file name. The path name is the name as known to the operating system. The file name 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 file name as the operand, just give the name. The name must be one already connected to a path name by a previously issued FILENAME statement. However, two special file names are recognized by the SAS/IML language: LOG and PRINT. These refer to the standard output streams for all SAS sessions. To specify a path name, enclose it in quotes or specify an expression in parentheses that yields the path name.
When the path name is specified, the operand is limited to 64 characters.
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 path name */
filename out "student.dat"; /* specify file name OUT */
file out; /* refer to by file name */
file print; /* standard print output */
file log; /* output to log */
file "student.dat" recfm=n; /* for a binary file */