FILE Statement: UNIX

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

Syntax

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

Required Argument

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

Optional Arguments

ENCODING='encoding-value'
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 Overview to SAS Language Elements That Use Encoding Values in SAS National Language Support (NLS): Reference Guide.
options
can be any of the options for the FILE statement that are valid in all operating environments. For a description of these options, see the SAS Statements: Reference.
host-options
are specific to UNIX environments. These options can be any of the following:
BLKSIZE=
BLK=
specifies the number of bytes that are physically written in one I/O operation. The default is 8K. The maximum is 1G–1.
TERMSTR=
controls the end-of-line or record delimiters in files formatted by UNIX or the PC. This option enables the sharing of these formatted files between the two hosts. The following are values for the TERMSTR= option:
CRLF Carriage return line feed. Use TERMSTR=CRLF to read files formatted by a PC.
LF Line feed. This parameter is used to read files formatted by UNIX. LF is the default.
Use TERMSTR=CRLF to read a file that was created on a PC. If the PC-formatted file was created using TERMSTR=LF, then the TERMSTR= option is unnecessary.
LRECL=
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.
MOD
indicates that data written to the file should be appended to the file.
NEW | OLD
specifies whether a new file or an existing file will be used for output. If you specify NEW, a new file is to be opened for output. If the file already exists, it is deleted and re-created. If you specify OLD, the previous contents of the file are replaced. NEW is the default.
RECFM=
specifies the record format. Values for the RECFM= option are the following:
D default format (same as variable).
F fixed format. That is, each record has the same length. Do not use RECFM=F for external files that contain carriage-control characters.
N binary format. The file consists of a stream of bytes with no record boundaries.
P print format. SAS writes carriage-control characters.
V variable format. Each record ends with a newline character.
S370V variable S370 record format (V).
S370VB variable block S370 record format (VB).
S370VBS variable block with spanned records S370 record format (VBS).
UNBUF
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.

Details

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.