Chapter Contents

Previous

Next
FILE

FILE



Specifies the current output file for PUT statements

Valid: in a DATA step
OS/390 specifics: file-specification, type, host-options


Syntax
Standard Host Options for the FILE Statement under OS/390
Host Options for Retrieving Information about Data Sets
VSAM Options for the FILE and INFILE Statements under OS/390
Options for UNIX System Services Files and Pipes
See Also

Syntax

FILE file-specification | LOG | PRINT <type> <options> <host-options>;

file-specification
identifies a file:

fileref
specifies a fileref or the allocated DDname of the file. A fileref must conform to the rules for DDnames. That is, it can consist of one to eight letters, numbers, or the national characters $, @, and #. 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.

The value of the FILEEXT= system option can affect the way SAS interprets PDS and PDSE member names. See FILEEXT= for details.

'physical-filename'
specifies a physical file, which can be a sequential file, a member of partitioned data set (PDS) or an extended partitioned data set (PDSE), or a UNIX System Services file, using the following syntax:

  • a UNIX System Services file:
    '/u/userid/raw'
    or
    'HFS:raw'

  • 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. For example:
    '.raw.data'

  • a partially qualified data set name with a period preceding and a member name in parentheses. For example:
    '.raw.data(mem1)'

  • a temporary data set name. For example:
    '&mytemp'

The value of the FILEEXT= system option can affect the way SAS interprets file specifications for PDS and PDSE files. See FILEEXT= for details.

See Specifying Physical Files for more information about partially qualified data set names.

LOG
directs output to the SAS log file.

PRINT
directs output to the SAS procedure output file.

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 OS/390 are

DLI
for IMS-DL/I databases. For information about IMS-DL/I options for the FILE statement, see SAS/ACCESS Interface to IMS-DL/I Software.

HFS
for UNIX System Services files, see Accessing UNIX System Services Files.

PIPE
for pipelines in UNIX System Services, see Piping Data from SAS to an UNIX System Services Command.

VSAM
for VSAM files (see Accessing VSAM Data Sets ).

options
are portable options that can be specified in the FILE statement. See SAS Language Reference: Dictionary for information about these options.

host-options
are host-specific options that can be specified in the FILE statement. You can specify portable options and host-options in any order. When specifying more than one option, use a blank space to separate each option. The host-options that you can specify depend on what type of file you are accessing. See the following sections for details:


Standard Host Options for the FILE Statement under OS/390

The following options can be used with all external files under OS/390.

BLKSIZE=value | BLK=value
specifies the block size of the file. Block size is discussed in more detail in DCB Option Descriptions and in Overview of DCB Attributes.

CLOSE=keyword
indicates how a tape volume is to be positioned at the end of the DATA step. Values for keyword can be
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 OS/390) to compress data on output. For example:
data _null_;
   file myfile csrc;
   put ... ;
run;

You cannot use this option with an external file that has a fixed-length record format.

DCB=fileref
gives 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 OS/390, the range of acceptable values of LINESIZE= is 64 to 256. The default value of the LINESIZE= system option under OS/390 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 value specified depends on the access method and the device type. For more information, see the discussion of LRECL= in DCB Option Descriptions and OS/390 JCL Reference.

MOD
writes the output lines following any existing lines in the file. This option overrides a disposition that was specified in JCL or under TSO. It is not valid if the specified file is a member of a partitioned data set (PDS).

NOPROMPT
specifies that if the file that you reference in the FILE statement is unavailable, a requestor window is not displayed and an error is written to the SAS log.

OLD
writes the output lines at the beginning of the file, causing any existing data in the file to be overwritten. This option overrides a disposition that was specified in JCL or under TSO, and it is the default if no disposition is specified. Using OLD is necessary only if you used MOD for the file in an earlier FILE statement and you want to overwrite the file.

PRINT|NOPRINT
specifies whether carriage-control characters are placed in output files. Under OS/390, PRINT adds carriage control characters to the beginning of all lines of output directed to print files and to the SAS log.

RECFM=record-format
specifies the record format of the file. Valid values are
F fixed length records, unblocked.
V variable length records, unblocked.
FB fixed length records, blocked.
VB variable length records, blocked.
U undefined length records, unblocked.

The following values can be appended to the values above:
A the first byte of each record is an ANSI printer-control character.
S if appended to V, the file contains spanned records; if appended to F, the file contains standard blocks.

The following value stands alone; no other values can be appended:
N a format specific to SAS; this format indicates that the file can be processed as a stream of bytes with no record boundaries.


Host Options for Retrieving Information about Data Sets

The following options retrieve information about a data set from the operating environment control blocks. SAS assigns values to the variables that are defined by these options when it opens the data set. It updates the values every time it opens a new data set in a concatenation. These options can be used with all standard external files under OS/390.

DEVTYPE=variable
defines a character variable (minimum length 24) that SAS sets to the device type. SAS obtains the device type by using the OS/390 operating environment DEVTYPE macro. For more information, see the IBM documentation for your system.

defines a character variable (minimum length 96) that SAS sets to the Data Set Control Block (DSCB) information from a non-VSAM data set. For more information, see the IBM documentation for your system.

JFCB=variable
defines a character variable (minimum length 176) that SAS sets to the Job File Control Block (JFCB). For more information, see the IBM documentation for your system.

UCBNAME=variable
defines a character variable (minimum length 3) that SAS sets to the unit name (device address), which is derived from information in the unit control block (UCB).

VOLUME=variable | VOLUMES=variable
defines a character variable (minimum length 6) that SAS sets to the tape VOLSER or the disk volume serial number, which is taken from the JFCB. The JFCB lists only the first five volume serial numbers, so in the case of a multivolume file, the VOLUME= variable contains the concatenated volume serial numbers (up to five volumes).


VSAM Options for the FILE and INFILE Statements under OS/390

The following options can be used for VSAM files in the FILE statement, the INFILE statement, or both. (Unless otherwise indicated, the option can be used in both.)

BACKWARD | BKWD
tells SAS to read the VSAM data set backwards. (INFILE only)

BUFND=value
indicates how many data buffers to use for the VSAM data set.

BUFNI=value
indicates how many index buffers to use for the VSAM data set.

CONTROLINTERVAL | CTLINTV | CNV
indicates that you want to read physical VSAM control interval records rather than logical records. This is typically used for diagnostic purposes. (INFILE only)

ERASE=variable
defines a numeric SAS variable that you must set to 1 when you want to erase a VSAM record. (INFILE only)

FEEDBACK=variable | FDBK=variable
defines a numeric variable that SAS will set to the VSAM logical error code. This is similar to the _FDBK_ automatic variable. When SAS sets the FEEDBACK variable, you must set it to 0 to continue.

GENKEY
causes SAS to use the KEY= variable as the leading portion of a record's key. VSAM retrieves the first record whose key matches the generic key. (INFILE only)

KEY=variable | KEY=(variable1 variable2 . . . )
indicates that direct keyed access is being used to read records either from a KSDS or from an ESDS via an alternate index. Also, the variable contains the key value to be used in the retrieval of a record (input) or the writing of a record (output). (INFILE ONLY)

KEYGE
is used in conjunction with the KEY= option. KEYGE indicates that when KEY= is used in a retrieval request, SAS should retrieve any record whose key is equal to or greater than the specified key. This is useful when the exact key is not known. (INFILE only)

KEYLEN=variable
specifies a numeric SAS variable that when used with GENKEY, specifies the length of the key that is to be compared to the keys in the file.

KEYPOS=variable
indicates the numeric variable that SAS sets to the position of the VSAM key field. This option enables you to read keys without knowing the key position in advance. This variable is set to the column number (starting from 1).

PASSWD=value
gives the appropriate password for a VSAM data set that has password protection.

RBA=variable
specifies a numeric variable that you set to the relative byte address (RBA) of the data record that you want to read. The RBA= option indicates that addressed direct access is being used; it is appropriate for KSDS and ESDS. If the CONTROLINTERVAL option is specified, the RBA= option can be used to access control records in an RRDS. (INFILE only)

RC4STOP
stops the DATA step from executing if when the VSAM data set is opened, a return code greater than 4 is returned by the system.

RECORDS=variable
defines a numeric variable that SAS sets to the number of logical records in a VSAM data set that has been opened for input.

RECORG=record-organization
specifies the organization of records in a new VSAM data set. Use this option only if SMS is active. Valid values are
KS VSAM key-sequenced data set
ES VSAM entry-sequenced data set
RR VSAM relative-record data set
LS VSAM linear-space data set

RESET
indicates that the VSAM file is to be reset to empty (no records) when it is opened. This option applies only to loading a VSAM data set that has been marked REUSE. This option cannot be used if the data set contains an alternate index.

RRN=variable
defines a numeric variable that you set to the relative record number (RRN) of the record that you want to read or write. This option indicates that keyed direct access is being used; it is appropriate for RRDS only.

SEQUENTIAL
specifies sequential VSAM record retrieval when either the RBA= (for an ESDS) or the RRN= option (for an RRDS) is specified. (INFILE only)

SKIP
indicates skip-sequential processing of VSAM files. Skip-sequential processing finds the first record whose value is the same as the value specified by the KEY= option; records are read sequentially from that point on. (INFILE only)

UPDATE=variable
defines a numeric SAS variable that tells SAS that not every record that it reads is to be updated. This option is used when you are updating records in a VSAM data set (INFILE only.) When you have both an INFILE and a FILE statement referencing the same VSAM data set, records are retrieved for update by default.

In most cases where you retrieve a record for update, no user, including you, can access that particular record or any other records in the same control interval until you free the record by executing a PUT or an INPUT statement for the data set. The UPDATE= option is used to avoid user lockout when only a few of many records read need to be updated. When you set the UPDATE= variable to a value of 1 before the INPUT statement, the record is retrieved for update. This is the default if UPDATE= is not specified. If you set UPDATE=0 before the INPUT statement, the record is not retrieved for update.


Options for UNIX System Services Files and Pipes

Several options can be specified in the FILE statement for files and pipes that are in the Hierarchical File System of UNIX System Services. For information about these options, see Host-Specific Options for UNIX System Services Files, Writing to External Files, Using the FILE Statement to Specify Data Set Attributes .

See Also


Chapter Contents

Previous

Next

Top of Page

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