Chapter Contents




Specifies the current output file for PUT statements

Valid: in a DATA step
CMS specifics: file-specification, host-options

Using the FILE Statement
Host Option Values
See Also


FILE file-specification <options>;
FILE file-specification | LOG | PRINT;
FILE 'pipe-specification' PIPE;

identifies the external file. See Identifying an External File for details on the following possible forms of the file-specification argument:

'filename filetype <filemode | *>'
specifies the filename, filetype, and filemode, respectively.

specifies the logical name associated with an external file, using 1-8 characters; the first character is either a letter (A-Z) or an underscore (_).

fileref(filename <filetype>)
specifies a member of the aggregate external file identified by the fileref. The aggregate must be an SFS directory or a CMS minidisk; it cannot be a MACLIB. If the filetype is not specified, the filename is used as the CMS filename and the filetype is assumed to be DATA.

specifies that lines produced by PUT statements are to be written in the SAS log. LOG is the default destination for output lines. Options cannot be specified with FILE LOG statements.

'pipe-specification' PIPE
specifies a standard CMS pipeline specification, which you can use to route output to any pipeline device driver. You cannot specify any options if you specify PIPE. For details on using pipeline specifications in your SAS programs, see Using CMS Pipelines .

specifies that lines produced by PUT statements are to be written to the same file as the output produced by SAS procedures. When the PRINT argument is the fileref, SAS uses carriage-control characters and writes the line with the characteristics of a print file. Options cannot be specified with FILE PRINT statements.

The options specified in a FILE statement control how SAS writes data into a file. In the CMS environment, the FILE statement accepts the following host options. When specifying more than one option, use a blank space to separate each option. Options are not accepted with FILE LOG, FILE PRINT, or FILE PIPE statements. Valid keywords are:

See Host Option Values for the values that can be assigned to the preceding keywords.

For information on portable options, see SAS Language Reference: Dictionary.


This section provides examples of FILE statement usage and describes the values available for FILE host-options.

Using the FILE Statement

Examples of using the FILE statement to write to CMS files follow.

data _null_;
   file 'mydata data *';
   put 'Test: writing to an external file';

In the preceding example, the FILE statement creates the file MYDATA DATA on the first R/W disk with these default characteristics: LRECL=80, RECFM=FB, and BLKSIZE=960.

filename mydata 'old mydata a';
data _null_;
   file mydata;
   put 'Test: writing to an external file';

In the preceding example, a fileref is assigned to create the file OLD MYDATA A with these default characteristics: LRECL=80, RECFM=FB, AND BLKSIZE=960. The fileref MYDATA is assigned by a FILENAME statement.

Host Option Values

The following file characteristics can be specified in the options argument in a FILE statement. Multiple options are separated by blank spaces.

See SAS Language Reference: Dictionary for information on portable options.

Note that options cannot be specified if you use FILE LOG, FILE PRINT, or FILE PIPE.

specifies the buffer size allocated to contain records. Valid values are 1 through 65535.

Records do not have to be blocked; however, because disk or tape activity is reduced when records are blocked, it is more efficient to use blocks. Blocking records is different when using CMS Native I/O Services than when using OS/MVS Simulation Services.

For CMS Native I/O Services, the following apply:

For MVS Simulated I/O Services, the following apply:

specifies tape density in bits per inch. Valid values include 200, 556, 800, 1600, 6250, 38K.

specifies the status (disposition) of the file. Acceptable values are
MOD specifies that output lines are to be written after any existing lines in the file.
OLD specifies that any output lines are to be written at the beginning of the file. This is the default. For CMS, this option is identical to the NEW option.
NEW specifies that any output lines are to be written at the beginning of the file. For CMS, this option is identical to the OLD option.

allows you to dynamically change input and output files in the middle of a DATA step.

indicates the type of label processing for a tape file. LABOFF is the default. Valid values are

If LABEL=SL, NL, or BLP is specified, an additional label value n can be specified after the SL, NL, or BLP. The value of n indicates the file position in a multifile volume. The default value is 1.

indicates that a multifile tape is not repositioned at open for LABOFF or BLP processing. For SL tapes, LEAVE=YES does not reposition before label processing. Omitting LEAVE or specifying LEAVE=NO causes a tape to be rewound and repositioned each time a file is opened. (See Working with SAS Files on Tape for details on tape processing.)

specifies the logical record length in bytes. Valid values are 1 through 65,535.

PRINT writes records to the file with ANSI printer control characters, making the output file a "print" file. Page headings are also produced. NOPRINT writes records without page headings or ANSI printer control characters.

specifies the format of records in the file.

You can choose one of the following record formats:
F specifies fixed-length records, unblocked.
FB specifies fixed-length records, blocked.
V specifies variable-length records, unblocked.
VB specifies variable-length records, blocked.
U specifies undefined-record format. For CMS disk files, this is the same as V.

You can use the following values in any of the previously listed formats except U.
A specifies that the first byte of each record is an ANSI printer control character and that the file is to be handled as a print file.
S specifies that the file contains spanned records (V), or the file contains standard blocks (F). FS, FBS, VS, and VBS files must be assigned with a CMS FILEDEF command.

passes an option string to a tape management system for standard label tapes. Entering a question mark (?) causes SAS to prompt you for option settings.

specifies the tape setting. Valid values are

specifies the volume serial number to be verified in the tape. If the value contains any special characters, it must be enclosed in single quotes.

See the FILEDEF command entry in VM/ESA CMS Command Reference, for more information about these options.

For more information about other options available in the FILE statement, see SAS Language Reference: Dictionary.

SAS does not interfere with FILEDEF options that are already specified. Therefore, TAPE options that are specified in the FILE, FILENAME, or INFILE statements that conflict with an existing FILEDEF to TAPE are ignored. See the appendix "Accessing SAS Data Libraries and External Files on Tape" in SAS Companion for the CMS Environment for more information.

If a variable-length file is opened for update (possibly in the DATA step) and if the replacement line is not the same length as the existing line, the standard CMS file system action truncates the file at that point. No message is given. The next read to that file returns EOF.

See Also

Chapter Contents



Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.