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

Syntax
Details
See Also

Syntax

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

file-specification

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

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 Encoding Values in SAS Language Elements in the 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. See the SAS Language Reference: Dictionary for a description of these options.

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 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:

CRLF

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

NL

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.

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

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.

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.


See Also

Previous Page | Next Page | Top of Page