FILE Command: UNIX

Writes the contents of the current window to an external file.
UNIX specifics: valid values for encoding-value and host-options

Syntax

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

Optional Arguments

file-specification
can be any of the following:
single filename
SAS writes the file in the current directory. If you enclose the filename in quotation marks, SAS uses the filename exactly as you specify it. If you do not enclose the filename in quotation marks and if you do not specify a filename extension, SAS uses .sas, .log, or .lst, depending on whether you issue the command from the Program Editor, Log, or Output window.
entire pathname
SAS does not assume any filename extensions, even if you do not enclose the pathname in quotation marks.
fileref
SAS specifies a fileref to assign to an external file.
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.
portable-options
are options for the FILE command that are valid in all operating environments. For more information about these options, see SAS System Options: 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.
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 spaces 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 truncated.
NEW|OLD
indicates that a new file is to be opened for output. If the file already exists, then it is deleted and re-created. This is the default action.
RECFM=
specifies the record format. Values for the RECFM= option are listed below:
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

If you do not enter a file specification, SAS uses the filename from the previous FILE or INCLUDE command. In this case, SAS first asks whether you want to overwrite the file. If you have not issued any FILE or INCLUDE commands, you receive an error message that indicates that no default file exists.