Chapter Contents

Previous

Next
SAS Companion for UNIX Environments

Assigning a Fileref to a Directory (Using Aggregate Syntax)

Aggregate syntax allows 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;
Aggregate syntax is especially useful when you have to refer to several files in one directory.

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). 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");
When you concatenate directory names, you can use aggregate syntax to refer to a file in one of the directories. For example, assume that the report.sas file resides in the directory associated with the MYPROGS environment variable. When the SAS System executes the following code, it searches for report.sas in the pathnames that are specified in the FILENAME statement and it executes the program.

filename progs ("$MYPROGS" "/users/mkt/progs");
%inc progs(report);

The SAS System searches the pathnames in the order specified in the FILENAME statement until


Chapter Contents

Previous

Next

Top of Page

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