Previous Page | Next Page

Allocating External Files

Using the FILENAME Statement or Function to Allocate External Files


Overview of Using the FILENAME Statement or Function to Allocate 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:

For further information about 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 . . . >;
fileref

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, and an underscore (_) can appear in any position of the name. You can subsequently use the fileref to refer to this file in your SAS session or batch job. (See Referring to External Files.)

device-type

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

'physical-filename' | ('physical-filename-1' . . . 'physical-filename-n') | 'physical-filename (*)' | 'physical-filename(beg*)' | 'physical-filename(*end)'

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.

options

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.

FILENAME Statement Examples
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;


Assigning Filerefs to Files on Other Systems (FTP, SFTP, and SOCKET Access Types)

You can access files on other systems in your network by using the FTP, SFTP, and SOCKET access methods. The forms of the FILENAME statement are:

FILENAME fileref FTP 'external-file' <ftp-options>;
FILENAME fileref SFTP 'external-file' <sftp-options>;
FILENAME fileref SOCKET 'hostname:portno' <tcpip-options>;
FILENAME fileref SOCKET ':portno' SERVER <tcpip-options>;

These access methods are documented in the SAS Language Reference: Dictionary. On z/OS, the FTP access method supports an additional option:

MACH='machine'

identifies which entry in the .netrc file should be used to get the user name and password. You cannot specify the MACH option and the HOST option on the same FILENAME statement. The .netrc file resides on z/OS.

The SAS FTP access method accesses the .netrc file per the following search precedence:

  1. NETRC DD statement

  2. userid.NETRC

  3. UFS Home directory (~/.netrc)

The .netrc file contains the machine name, user ID, and password of various hosts that a user can FTP to, for example:

MACHINE hostname LOGIN userid PASSWORD xxxxxxx

If you are transferring a file to any UNIX or Windows file system from SAS in the z/OS operating environment and you want to use either the S370V or S370VB format to access that file, then the file must be of type RECFM=U and BLKSIZE=32760 before you transfer it.

Note:   

  [cautionend]

Previous Page | Next Page | Top of Page