Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
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 filepaths).

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, "File Access."

The file-name is either a predefined filename or a quoted string or character expression in parentheses referring to the filepath. There are two ways to refer to an input or output file: by a filepath and by a filename. The filepath 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 filepath 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 filepath, put it in quotes or specify an expression yielding the filepath in parentheses.

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

Below are several valid uses of FILE statement.

   file "student.dat";           /* by literal filepath   */

   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     */

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

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