INFILE Statement: z/OS

Specifies an external file to read with an INPUT statement.
Valid in: In a DATA step
z/OS specifics: file-specification, type, host-options
See: INFILE Statement in SAS Statements: Reference

Syntax

INFILE file-specification <type> <ENCODING=encoding-value> <options> ;
INFILE DATALINES | CARDS <options> ;

Required Arguments

file-specification
identifies a file in one of the following forms:
fileref
specifies the assigned fileref or the allocated ddname of the file. A fileref must conform to the rules for ddnames. That is, it can consist of up to eight letters, numbers, or national characters ($, @, and #) and underscores (_). The first character must be either a letter or a national character.
fileref(member)
specifies a member of a partitioned data set, where the PDS or PDSE is specified by the assigned fileref or allocated ddname.
If you specify a fileref that is not allocated, then SAS attempts to construct a data set name with the following three qualifiers:
  • the value of the SYSPREF= option (usually the user ID)
  • the specified fileref
  • DATA
If a file is found that has this constructed data set name, then SAS opens it and reads it.
The value of the FILEEXT= system option can affect the way SAS interprets PDS and PDSE member names. For more information, see FILEEXT= System Option: z/OS.
'physical-filename'
specifies a physical file, which can be a member of a partitioned data set (PDS), an extended partitioned data set (PDSE), or a UNIX System Services file, using the following syntax:
  • a fully qualified data set name. For example:
    'myid.raw.datax'
  • a fully qualified data set name with a member in parentheses. For example:
    'sas.raw.data(mem1)'
  • a partially qualified data set name with a period preceding it. For example:
    '.raw.data'
  • a partially qualified data set name with a period preceding it and a member name in parentheses. For example:
    '.raw.data(mem1)'
  • for PDS members, a fully or partially qualified data set name with a wildcard name in parentheses. For example:
    '.raw.data(mem*)'
    '.raw.data(*mem1)'
    '.raw.data(*)'
  • a UNIX System Services file. For example:
    '/u/userid/raw'
    or
    'HFS:raw'
    or
    '/u/userid/data/*'
    The * wildcard character indicates a concatenation of UNIX System Services files. For more information about the use of the wildcard, see Concatenating UNIX System Services Files.
The value of the FILEEXT= system option can affect the way SAS interprets file specifications for PDS and PDSE files. For more information, see FILEEXT= System Option: z/OS.
For more information about partially qualified data set names, see Specifying Physical Files. For information about encodings for z/OS resources such as data set names and UFS paths, see Encoding for z/OS Resource Names.
DATALINES | CARDS
specifies that input data immediately follows a DATALINES or CARDS statement in your SAS program.

Optional Arguments

type
specifies the type of file. When you omit type, the default is a standard external file. Nonstandard (host-specific) file types that you can specify for z/OS are
DLI
for IMS-DL/I databases. For information about IMS-DL/I options for the FILE statement, see SAS/ACCESS(R) 9.3 Interface to IMS: Reference.
HFS
for UNIX System Services. For information about files in the UNIX System Services, see Accessing UNIX System Services Files.
MVS
for z/OS data sets.
PIPE
opens a pipe to issue UNIX System Services commands from within the statement. For information about files in the UNIX System Services, see Piping Data from SAS to a UNIX System Services Command.
IDMS
for CA-IDMS files. For information about CA-IDMS options for the INFILE statement, see SAS/ACCESS(R) 9.3 Interface to IMS: Reference.
ISAM
for information about ISAM files, see Accessing ISAM Files.
VSAM
for VSAM files. For information about VSAM files, see Accessing Nonstandard Files .
VTOC
for a Volume Table of Contents (VTOC).
ENCODING= encoding-value
specifies the encoding to use when reading from the input file. Typically, you would specify a value for ENCODING= that indicates that the input file has a different encoding from the current session encoding. However, you can also specify the same encoding for the input file as the encoding of the current session. You must enclose the value in quotation marks if it contains a hyphen.
If you specify an encoding value different from the session encoding, SAS transcodes the data from the session encoding to the specified encoding when you read data from the input file. The default encoding is the session encoding, which is the value of the ENCODING= SAS system option.
For valid encoding values, see Overview to SAS Language Elements That Use Encoding Values in SAS National Language Support (NLS): Reference Guide and SBCS, DBCS, and Unicode Encoding Values for Transcoding Data in SAS National Language Support (NLS): Reference Guide.
options
are either portable or host-specific. For information about portable options, see SAS System Options: Reference.
You can specify portable options and host options in any order. When you specify more than one option, separate the options with a blank space.
The host-options that you can specify depend on which type of external file is being accessed. See the following sections for details:

Details

Standard Options for the INFILE Statement under z/OS

You can use the following standard options with all standard external files under z/OS.
BLKSIZE=value | BLK=value
specifies the block size of the file. Block size is discussed in more detail in DCB Attribute Options.
CCHHR=variable
specifies a character variable to which the physical address (cylinder head record) of a record is returned. This applies to files on CKD disks only.
CLOSE=keyword
indicates how a tape volume is positioned at the end of the DATA step. Values for keyword are
REREAD
positions the tape at the logical beginning of the data set.
LEAVE
positions the tape at the logical end of the data set.
REWIND
rewinds the tape to the physical beginning of the volume.
FREE
dynamically deallocates the tape volume.
DISP
is implied by the control language.
CSRC
specifies that you want to use the CSRCESRV services (available with z/OS) to decompress data on input. For example:
data;
   infile myfile csrc;
   input;
run;
DCB=fileref
specifies the fileref of an external file that was referenced in an earlier FILE or INFILE statement in the same DATA step. SAS uses that file's RECFM=, LRECL=, and BLKSIZE= information for the current file.
LINESIZE=width
works with LRECL to specify the maximum number of characters per line or record in print files, nonprint files, and the SAS log. Under z/OS, the range of acceptable values of LINESIZE= is 64 to 256. The default value of the LINESIZE= system option under z/OS is 132. This default applies only to print files (with carriage returns) or to the SAS log. For nonprint files (without carriage returns), the value of LRECL= is used in place of the default value for LINESIZE=.
LRECL=value
specifies the logical record length of the file. The specified value depends on the access method and the device type. For more information, see the discussion of LRECL= in DCB Option Descriptions and in the IBM MVS JCL Reference.
RECFM=record-format
specifies the record format of the file. Valid values are
F
specifies fixed-length records, unblocked.
V
specifies variable-length records, unblocked.
FB
specifies fixed-length records, blocked.
VB
specifies variable-length records, blocked.
U
specifies undefined-length records, unblocked.
The following values can be appended to the RECFM= values:
A
specifies that the first byte of each record is an ANSI printer-control character.
M
specifies that the file is a machine control character file. SAS does not interpret machine code control characters, nor does it create them in output files. See MVS JCL Reference by IBM for more information.
S
specifies that the file contains spanned records (V), or the file contains standard blocks (F).
The following value stands alone; no other values can be appended:
N
indicates that the file is in binary format. The file is processed as a stream of bytes with no record boundaries, which includes the default value of LRECL. This record format is specific to SAS.

Host Options for Retrieving Information about Data Sets

For information about options that retrieve information about a data set from operating environment control blocks, see Host Options for Retrieving Information about Data Sets.

VTOC Options for the INFILE Statement under z/OS

The following options are used only in INFILE statements that involve VTOC (Volume Table of Contents) access:
CCHHR=variable
defines a SAS character variable of length 5 whose value is set to the CCHHR of the last VTOC record that was read by SAS. The returned value is in hexadecimal format; it can be printed by using the $HEX10. SAS format.
CVAF
tells SAS to use the Common VTOC Access Facility (CVAF) of the IBM program product Data Facility/Device Support (DF/DS) for indexed VTOCs. If the VTOC is not indexed, or if your installation does not have CVAF, this option is ignored.
Note: When you use CVAF and CCHHR=, values that are returned for Format-5 DSCB records are not valid, because indexed VTOCs do not have Format-5 DSCB records.

Host-Specific Options for UNIX System Services Files

The following table shows which host-specific options are recognized by the FILENAME, FILE, and INFILE statements for UNIX System Services files and pipes. No other options are recognized, including such options specific to z/OS as DISP, CLOSE, and DCB. Descriptions of the options follow the table.
Host-Specific Options for UNIX System Services Files and Pipes
Option
FILENAME
FILE
INFILE
%INCLUDE
BLKSIZE=
X
X
X
X
FILEDATA=
X
X
X
OLD
X
X
MOD
X
X
LRECL=
X
X
X
X
RECFM=
X
X
X
X
TERMSTR=
X
X
X
BLKSIZE=
specifies the number of bytes that are physically read or written in an I/O operation. The default is 8K. The maximum is 1M.
FILEDATA=BINARY | TEXT
The FILEDATA= option specifies that the file being processed is expected to contain one of the following:
BINARY
data without record separator character sequences.
TEXT
data with records terminated by the EBCDIC newline character. The EBCDIC newline character is defined at code point x'15' and is typically represented as NL or \n.
Note: The FILEDATA= option is meant to be similar to the FILEDATA= parameter on the DD JCL statement, but is evaluated at run time by SAS. The JCL parameter is used by z/OS to set an attribute of the file when the file is created by the JCL
OLD
replaces the previous contents of the file. This option is the default. This option has no effect on a pipe.
MOD
appends the output lines to the file. This option has no effect on a pipe.
LRECL=value
specifies the maximum number of characters in a line (unless the file has been opened with RECFM=N). The default is 255. Lines longer than value are truncated. value must be between 1 and 65,535, inclusive.
RECFM=record-format
specifies the record format of the file. Valid values are
F
specifies that all lines in the file have the length specified in the LRECL= option. In output files, lines that are shorter than the LRECL= value are padded on the right with blanks.
V | D
specifies that the lines in the file are of variable length, ranging from one character to the number of characters specified by LRECL=. This option is the default.
P
specifies that the file has variable-length records and is in print format.
N
specifies that the file is in binary format. The file is treated as a byte stream. That is, line boundaries are not recognized.
TERMSTR=NONE | NL | CR | LF | CRLF | LFCR | CRNL
The TERMSTR= option specifies the type of record separator character sequences to use to terminate records in the file. TERMSTR= accepts the following parameters:
NONE
Record terminators are not used. This parameter provides the same function as FILEDATA=BINARY.
NL
The newline character (x'15') is used as the record terminator. This parameter provides the same function as FILEDATA=TEXT.
CR
The carriage return character (x'0C') is used as the record terminator.
LF
The line feed character (x'25') is used as the record terminator.
CRLF
The sequence CR followed by LF is used as the record terminator.
LFCR
The sequence LF followed by CR is used as the record terminator.
CRNL
The sequence CR followed by NL is used as the record terminator.
All of the above specifications (x'15', x'0C', and x'25') assume that the files use an ENCODING= value whose short (12 byte) name is in the form open_ed-nnnn and whose long (32 byte) name contains (OpenEdition) (for example, open_ed-1047 or Western(OpenEdition)). These characters are automatically transcoded to or from the file's encoding if they are required by the ENCODING= or LOCALE= options.
The last occurrence of FILEDATA= or TERMSTR= takes precedence. Specification of one or the other of these options on a FILE or INFILE statement takes precedence over the specification in a related FILENAME statement.
The full precedence order is as follows:
  1. Specification of FILEDATA= or TERMSTR= on a FILE or INFILE statement.
  2. Specification of FILEDATA= or TERMSTR= on a FILENAME statement.
  3. Specification of FILEDATA= on a DD JCL statement when the file was created by that DD statement.
  4. Implied by the RECFM= option in effect for the file.
    The RECFM= option in the FILENAME, FILE, and INFILE statement can imply the value assumed for the termination sequence. This implication is always overridden by the presence of a TERMSTR= or FILEDATA= option for the file. Here are the default values:
RECFM=V | D
TERMSTR=NL is implied. (This option is the default.)
RECFM=F
TERMSTR=NONE is implied.
RECFM=P
TERMSTR=NL implied, along with other formatting control characters.
RECFM=N
TERMSTR=NONE is implied.
Note: The FILEDATA= parameter on the DD JCL statement is used only by z/OS when the file is being created by that JCL statement. For existing files, the FILEDATA= parameter is ignored by z/OS, and SAS is informed of its value at file creation time. Therefore, SAS cannot detect a change in the JCL. However, SAS will honor the values of FILEDATA= or TERMSTR= that are specified in the FILENAME, INFILE, or FILE statements when you replace an existing file or read a file.
CAUTION:
The combination of RECFM= and TERMSTR= provides much flexibility for reading and writing many different file formats. It is possible to use these options in a way that can produce a file that might be difficult to process in the future. For example, a PRINT file can be created without record terminators, but this file would look strange when printed on a printer or viewed in an editor.