Previous Page | Next Page

Statements under UNIX

FILE Statement: UNIX

Specifies the current output file for PUT statements.
Valid: in a DATA step
UNIX specifics: valid values for file-specification, host-options, and encoding-value
See: FILE Statement in SAS Language Reference: Dictionary

See Also


FILE file-specification <ENCODING='encoding-value' > <options> <host-options>;


can be any of the file specification forms that are discussed in the Accessing an External File or Device in UNIX Environments.


specifies the encoding to use when writing to the output file. The value for ENCODING= indicates that the output file has a different encoding from the current session encoding.

When you write data to the output file, SAS transcodes the data from the session encoding to the specified encoding.

For valid encoding values, see Encoding Values in SAS Language Elements in the SAS National Language Support (NLS): Reference Guide.


can be any of the options for the FILE statement that are valid in all operating environments. See the SAS Language Reference: Dictionary for a description of these options.


are specific to UNIX environments. These options can be any of the following:


specifies the number of bytes that are physically written in one I/O operation. The default is 8K. The maximum is 1G-1.


controls the end-of-line or record delimiters in PC- and UNIX-formatted files. This option enables the sharing of UNIX- and PC-formatted files between the two hosts. The following are values for the TERMSTR= option:


Carriage Return Line Feed. This parameter is used to create PC format files.


Newline. This parameter is used to create UNIX format files. NL is the default format.

Use TERMSTR=CRLF when you are writing to a file that you want to read on a PC. If you use this option when creating the file, then you do not need to use TERMSTR=NL when reading the file on the PC.


specifies the logical record length. Its meaning depends on the record format in effect (RECFM). The default is 256. The maximum length is 1G.

  • If RECFM=F, then the value for the LRECL= option determines the length of each output record. The output record is truncated or padded with blanks to fit the specified size.

  • If RECFM=N, then the value for the LRECL= option must be at least 256.

  • If RECFM=V, then the value for the LRECL= option determines the maximum record length. Records that are longer than the specified length are divided into multiple records.


indicates that data written to the file should be appended to the file.


indicates that a new file is to be opened for output. If the file already exists, then it is deleted and re-created. If you specify OLD, then the previous contents of the file are replaced. NEW is the default.


specifies the record format. Values for the RECFM= option are the following:


default format (same as variable).


fixed format. That is, each record has the same length. Do not use RECFM=F for external files that contain carriage-control characters.


binary format. The file consists of a stream of bytes with no record boundaries.


print format. SAS writes carriage-control characters.


variable format. Each record ends with a newline character.


variable S370 record format (V).


variable block S370 record format (VB).


variable block with spanned records S370 record format (VBS).


tells SAS not to perform buffered writes to the file on any subsequent FILE statement. This option applies especially when you are writing to a data collection device.


The ENCODING= option is valid only when the FILE statement includes a file specification that is not a reserved fileref. If the FILE statement includes the ENCODING= argument and the reserved filerefs Log or Print as the file-specification, then SAS issues an error message. The ENCODING= value in the FILE statement overrides the value of the ENCODING= system option.

You can set the permissions of the output file by issuing the umask command from within the SAS session. For more information, see Executing Operating System Commands from Your SAS Session.

See Also

Previous Page | Next Page | Top of Page