Chapter Contents

Previous

Next
SAS Companion for the OS/390 Environment

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 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 an HFS file, one of the following actions occurs:

For further information on the FILENAME function, see FILENAME.


FILENAME Statement Syntax

This section provides only a brief overview of FILENAME statement syntax. For complete information about the FILENAME statement, see FILENAME.

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. 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 file name of the data set, enclosed in quotes (see Specifying Physical Files), or it can be a concatenation of physical file names. For a concatenation, enclose each data set name in quotes, and enclose the entire group of file-specifications in parentheses. The maximum number of data sets in a concatenation is 255.

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. Generally, values for options may be specified either with or without quotes. However, values that contain special characters must be enclosed in quotes.


FILENAME Statement Examples

The following table provides examples of the FILENAME statement for OS/390.

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;
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;
UNIX System Services: 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*)';
terminal n/a
filename term1  '*';
        or
filename term2 terminal;
printer n/a
filename prnt unit=printer sysout=a;
        or
filename prnt printer sysout=a;


Chapter Contents

Previous

Next

Top of Page

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