Previous Page | Next Page

External Files

Referencing Many External Files Efficiently

When you use many files from a single aggregate storage location, such as a directory or partitioned data set (PDS or MACLIB), you can use a single fileref, followed by a filename enclosed in parentheses, to access the individual files. This saves time by eliminating the need to type a long file storage location name repeatedly. It also makes changing the program easier later if you change the file storage location. The following table shows an example of assigning a fileref to an aggregate storage location:

Referencing Many Files Efficiently
External File Task Tool Example
Assign a fileref to aggregate storage location. FILENAME
filename mydir 'directory-or-PDS-name';
Specify the file that contains input data. INFILE
data weight;
   infile mydir(;
   input idno $ week1 week16;
Specify the file that the PUT statement writes to. (table note 1) FILE
   file mydir(awards);
      if loss ge 5 then put idno loss 
        'AWARD STATUS=3';
           else if loss ge 10 
              then put idno loss 'AWARD STATUS=2';
           else if loss ge 15 
              then put idno loss 'AWARD STATUS=1';
Bring statements or raw data from another file into your SAS job and execute them. %INCLUDE %include mydir(whole.program);

TABLE NOTE 1:   SAS creates a file that is named with the appropriate extension for your operating environment. [arrow]

Previous Page | Next Page | Top of Page