Previous Page | Next Page

Statements under UNIX

INFILE Statement: UNIX



Identifies an external file to read with an INPUT statement.
Valid: in a DATA step
UNIX specifics: valid values for encoding-value, file-specification, and host-options
See: INFILE Statement in SAS Language Reference: Dictionary

Syntax
Details
See Also

Syntax

INFILE 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 reading from the external file. The value for ENCODING= indicates that the external file has a different encoding from the current session encoding.

When you read data from an external file, SAS transcodes the data from the specified encoding to the session encoding.

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

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

CR

Carriage return. Use TERMSTR=CR to read files formatted by Apple Macintosh.

CRLF

Carriage Return Line Feed. Use TERMSTR=CRLF to read files formatted by a PC.

LF

LineFeed. 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 number of bytes to be read as one record.

  • 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.

RECFM=

specifies the record format. The following values are valid under UNIX:

D

default format (same as variable).

F

fixed format. That is, each record has the same length.

N

binary format. The file consists of a stream of bytes with no record boundaries. If you do not specify the LRECL option, then, by default, SAS reads 256 bytes at a time from the file.

P

print format.

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).


Details

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


See Also

Previous Page | Next Page | Top of Page