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:

Table 39.3: 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(qrt1.data);   input idno $ week1 week16;   loss=week1-week16;  

Specify the file that the PUT statement writes to. [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';   run;  

Bring statements or raw data from another file into your SAS job and execute them.

%INCLUDE

  %include mydir(whole.program);  

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




SAS 9.1 Language Reference. Concepts
SAS 9.1 Language Reference Concepts
ISBN: 1590471989
EAN: 2147483647
Year: 2004
Pages: 255

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net