Previous Page | Next Page

Statements under OpenVMS

FILE Statement: OpenVMS

Specifies the current output file for PUT statements.
Valid: in a DATA step
OpenVMS specifics: valid values for file-specification, host-option-list, and encoding-value
See: FILE Statement in SAS Language Reference: Dictionary

See Also


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


can be any type of file specification discussed in Identifying External Files to SAS.


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 SAS National Language Support (NLS): Reference Guide.


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


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


For information about these options, see Host-Specific External I/O Statement Options in the FILENAME statement.

Many of the DCL print qualifiers are also supported as host options in the FILE and FILENAME statements. For details, see Printer Options in the FILENAME and FILE Statements in the FILENAME statement.

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

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


By default, PUT statement output is written to the SAS log. Use the FILE statement to route this output to either the same external file to which procedure output is written or to a different external file. You can indicate whether carriage-control characters should be added to the file.

You can use the FILE statement in conditional (IF-THEN) processing because it is executable. You can also use multiple FILE statements to write to more than one external file in a single DATA step.

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= option 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.


The following is an example of a FILE statement:

file prices;

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

When SAS writes a file, it creates a new version by default. For example, if your default directory contains versions 1 and 2 of the file PRICES.DAT, then this FILE statement writes PRICES.DAT;3 in your default directory.

If you want to append output lines to the most recent version of an external file, use the MOD option in the FILE statement. For instance, from the previous example your default directory contains three versions of PRICES.DAT. The following statement appends data lines to PRICES.DAT;3:

file prices mod;

To reference an explicit version of a file, use the version number as part of the file specification within a quoted string. For example, the following FILE statement writes to version 1 of the file:

file 'prices.dat;1';

See Also

Previous Page | Next Page | Top of Page