INFILE Statement: Windows

Specifies an external file to read with an INPUT statement.

Valid in: a DATA step
Windows specifics: Valid values for encoding-value, file-specification, and host-options
See: INFILE Statement in SAS Statements: Reference

Syntax

Required Argument

file-specification

identifies the source of input data records, usually an external file. The file-specification argument can be any of the file specification forms that are discussed in Referencing External Files. The reserved fileref CARDS enables the INFILE statement to reference instream data.

The words AUX, CON, NUL, PRN, LPT1 - LPT9, and COM1 - COM9 are reserved words under Windows. Do not use them as filerefs.

Optional Arguments

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

names external I/O statement options that are specific to the Windows operating environment. They can be any of the following:

BLKSIZE= block-sizeBLK=block-size

specifies the number of bytes that are physically read or written in an I/O operation. The default is 8K. The maximum is 1M.

BLOCK | NOBLOCK

is used only in the context of named pipes. This option indicates whether the client is to wait if no data is currently available. The default value is BLOCK.

BYTE | MESSAGE

is used only in the context of named pipes. This option indicates the type of pipe. The default value is BYTE.

COMTIMEOUT=value

controls how a communications port time-out is handled. A time-out occurs when no data is available at the communications port for a period of time, usually 60 seconds. The COMTIMEOUT= option can have the following values:

EOF

returns an end-of-file (EOF) character when a time-out occurs. This behavior is the default. The EOF character causes the current DATA step to terminate.

WAIT

instructs the communications port to wait forever for data. This value overrides the time-out. In this case, no record is returned to the DATA step until data are available. This action can cause your program to go into an infinite loop, so use this value with caution.

EOFCONNECT

is used only in the context of named pipes and is valid only when defining the server. This option indicates that if an end-of-file (EOF) character is received from a client, the server should try to connect to the next client.

ZERO

returns a record length of 0 bytes when a time-out occurs. However, the DATA step does not terminate; it simply tries to read data again.

HOTLINK

is used only in the context of Dynamic Data Exchange (DDE). For a complete description and an example of using this option, see Using the DDE HOTLINK.

IGNOREDOSEOF

is used in the context of I/O operations on variable record format files. When this option is specified, any occurrence of ^Z is interpreted as character data and not as an end-of-file marker.

LRECL=record-length

specifies the record length (in bytes). Under Windows, the default is 32767. The value of record-length can range from 1 to 1,073,741,823 (1 gigabyte).

NOTAB

is used only in the context of Dynamic Data Exchange (DDE). This option enables you to use nontab character delimiters between variables. For more information about this option, see Using the NOTAB Option with DDE.

PIPE

specifies an unnamed pipe.

Requirement You must specify a file-specification reference and the file-specification reference must contain an absolute path and filename enclosed in quotation marks.

RECFM=record-format

controls the record format. The following values are valid under Windows:

F indicates fixed format.
N indicates binary format and causes the file to be treated as a byte stream. If LRECL is not specified, by default SAS reads 32767 bytes at a time from the file.
P indicates print format.
S370V indicates the variable S370 record format (V).
S370VB indicates the variable block S370 record format (VB).
S370VBS indicates the variable block with spanned records S370 record format (VBS).
V | D indicates variable format. This format is the default.
The S370 values are valid with z/OS types of files only. That is, they are valid in files that are binary, have variable-length records, and are in EBCDIC format. If you want to use a fixed-format z/OS file, first copy it to a variable-length, binary z/OS file.

RETRY=seconds

is used only in the context of named pipes. This option specifies how long a named pipe client should wait for a busy pipe. The minimum (and default) value for seconds is 10.

SERVER | CLIENT

is used only in the context of named pipes. This option specifies the mode of a named pipe. The default value is SERVER.

TERMSTR=

specifies the end-of-line character for the file. Use this option to share files between the UNIX and Windows operating environments. If termstr is not specified, a single LF or a CRLF function as the end of line character. If termstr=CRLF, then CRLF functions as the EOL character. The following values are valid are under Windows:

CRLF

Carriage return line feed. Use TERMSTR=CRLF to read files that are formatted for Windows or DOS. CRLF is the default.

LF

Line feed. Use TERMSTR=LF to read files that are formatted for UNIX. If a file contains CRLF characters, the CR functions as part of the data and not an end of line character.

CR

Carriage Return. Use TERMSTR=CR if the end of line character is a CR.

Details

If the INFILE statement includes the ENCODING argument and CARDS, CARDS4, DATALINES, or DATALINES4 as the file-specification, then SAS issues an error message. The ENCODING value in the INFILE statement overrides the value of the ENCODING system option.

Example: Referencing External Files

You can reference external files from a concatenated list of files or directories. The wildcard character * can be used in the INFILE statement:
data new;
infile '("c:\myfiles\*.*","c:\myotherfiles\abc.dat")';
input;
run;