| Allocating External Files |
The FILENAME statement and FILENAME function associate a SAS fileref (file reference name) with the operating environment's name for an external file. This association is equivalent to allocating a physical file externally (using a JCL DD statement or a TSO ALLOCATE command) and assigning a fileref to it.
In interactive mode, if you issue a FILENAME statement or function or attempt to allocate a file with the FNAME window for a file that does not exist, and if you do not specify DISP=NEW, and if the file is not a UFS file, one of the following actions occurs:
If the SAS system option FILEPROMPT is in effect (the default), then a dialog box asks whether you want to create the external file. If you reply Yes , SAS creates the external file, using any attributes that you specified in the FILENAME statement. If you do not specify any attributes, SAS uses the values of the SAS system options FILEDEV=, FILEVOL=, FILEUNIT=, FILESPPRI=, and FILESPSEC=. See System Options in the z/OS Environment for information about these options.
If the SAS system option NOFILEPROMPT is in effect, an error message indicating that the file could not be allocated is written to the SAS log.
For further information on the FILENAME function, see FILENAME Function: z/OS.
| FILENAME Statement Syntax |
This section provides only a brief overview of FILENAME statement syntax. For complete information about the FILENAME statement, see FILENAME Statement: z/OS.
The syntax of the FILENAME statement is
| FILENAME fileref <device-type > `physical-filename' <options . . . >; |
identifies the external file. The 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. You can subsequently use the fileref to refer to this file in your SAS session or batch job. (See Referring to External Files.)
enables you to route output to an output device, disk, or tape file by specifying device type. If device-type is not defined for a new file, its value is taken from the SAS system option FILEDEV=.
is the physical filename of the data set, enclosed in quotation marks (see Specifying Physical Files), or it can be a concatenation of physical filenames. For a concatenation, enclose each data set name in quotation marks, and enclose the entire group of file-specifications in parentheses. The maximum number of data sets in a concatenation is 200.
For a concatenation of members in a PDS, an asterisk (*) can be used in a wildcard file specification. The syntax `physical-filename (*)' applies to all members of the PDS; (beg*) applies to all members or files whose names begin with beg, and (*end) applies to all files whose names end with end.
include standard options such as file disposition as well as options for SYSOUT data sets such as the destination for output and the number of copies desired. These options are described in detail in FILENAME Statement: z/OS. Generally, values for options can be specified either with or without quotation marks. However, values that contain special characters must be enclosed in quotation marks.
| FILENAME Statement Examples |
The following table provides examples of the FILENAME statement for z/OS.
| Type of File | New or Existing File? | Example |
|---|---|---|
| sequential | existing |
filename raw 'myid.raw.datax' disp=old; |
| new |
filename x 'userid.newdata' disp=new space=(trk,(5,1)) unit=3380 volume=xyzabc recfm=fb lrecl=80 blksize=6160; |
|
| member of partitioned | existing |
filename raw 'sas.raw.data(mem1)' disp=old; |
| new |
filename dogcat 'userid.sas8.physn(optwrk)' disp=new space=(trk,(1,3,1)) volume=xxx111 recfm=fb lrecl=255 blksize=6120 dsorg=po; |
|
| partitioned extended | existing |
filename mypdse 'sas.test.pdse' disp=old; |
| new |
filename tpdse 'sas.test.pdse' dsntype=library space=(trk,(5,2,2)) lrecl=80 blksize=6160 recfm=fb disp=(new,catlg) dsorg=po; |
|
| UFS: HFS files | existing |
filename myhfs '/u/userid/myfile'; |
| new |
filename myhfs '/u/userid/myfile'; |
|
| temporary | new |
filename nextone '&mytemp' disp=new space=(trk,(3)) lrecl=80 blksize=6160; |
| tape | existing |
filename mytape 'prod.data' vol=myvol unit=tape label=(1,SL); |
| new |
filename tranfile 'sas.cport.file' label=(1,SL) vol='042627' unit=cart blksize=8000 disp=(new,keep); |
|
| concatenated | existing |
filename concat12 ('prod.payroll.data' 'prod.trans(may)'); |
| wildcard | existing, in PDS |
filename wild 'prod.payroll(d*)'; |
| existing, in HFS |
filename all '/u/userid/*.sas'; |
|
| terminal | not applicable |
filename term1 '*'; or filename term2 terminal; |
| printer | not applicable |
filename prnt unit=printer sysout=a; or filename prnt printer sysout=a; |
Copyright © 2007 by SAS Institute Inc., Cary, NC, USA. All rights reserved.