Previous Page | Next Page

Statements under OpenVMS

INFILE Statement: OpenVMS

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

See Also


INFILE file-specification <ENCODING='encoding-value'><option-list>


identifies the source of the input data records (usually an external file). It can be any of the file specification forms discussed in Identifying External Files to SAS. The reserved fileref DATALINES allows the INFILE statement to read instream data.


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.


names options for the INFILE statement that are valid in all operating environments. For information about these options, see the INFILE statement in SAS Language Reference: Dictionary.


names external I/O statement options for the INFILE statement that are specific to the OpenVMS environment. These options can be any of the following:


For an explanation of these options, see Host-Specific External I/O Statement Options in the FILENAME statement.

You can intersperse options from option-list and host-option-list in any order.

Note:   When you are using the PIPE device with the INFILE statement, only the LRECL= host option is supported.  [cautionend]


Because the INFILE statement identifies the file to read, it must execute before the INPUT statement that reads the input data records. You can use the INFILE statement in conditional processing, such as an IF-THEN statement, because it is executable. This enables you to control the source of the input data records.

When you use more than one INFILE statement for the same file specification and you use options in each INFILE statement, the effect is additive. To avoid confusion, use all the options in the first INFILE statement for a given external file.

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.


The following is an example of an INFILE statement:

infile food;

This INFILE statement uses the default filename form of the file specification (FOOD has not been assigned as a SAS fileref or as an OpenVMS logical name). Therefore, SAS looks for the file FOOD.DAT in the current directory.

When SAS reads a file, it uses the most recent version by default. For example, if your default directory contains the files FOOD.DAT;1, FOOD.DAT;2, and FOOD.DAT;3, this INFILE statement reads FOOD.DAT;3.

See Also

Previous Page | Next Page | Top of Page