Using External Files and Devices |
Introduction to Aggregate Syntax |
Aggregate syntax enables you to assign a fileref to a directory and then work with any file in that directory by specifying its filename in parentheses after the fileref.
FILENAME fileref directory-name; |
To refer to a file in the directory, specify the fileref followed by the individual filename in parentheses. For example, you can refer to the file cars.dat in the directory /users/pat as shown in this example:
filename prices '/users/pat'; data current.list; file prices(cars); ...other SAS statements... run;
You can also use aggregate syntax with filerefs that have been defined using environment variables. (See Using Environment Variables to Assign Filerefs in UNIX Environments.) For example:
x setenv PRICES /users/pat; data current.list; file prices(cars); ...other SAS statements... run;
Assigning a Fileref to Several Directories |
In the FILENAME statement, you can concatenate directory names and use the fileref to refer to any file within those directories:
FILENAME fileref ("directory-1" ... "directory-n"); |
filename progs ("$MYPROGS" "/users/mkt/progs"); %inc progs(report);
SAS searches the pathnames in the order specified in the FILENAME statement until
it finds the first file with the specified name. Even if you use wildcards (see Using Wildcards in Pathnames (Input Only)) in the filename, SAS matches only one file.
it encounters a filename in the list of pathnames that you specified in the FILENAME statement.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.