Referencing External Files Indirectly


If you want to reference a file in only one place in a program so that you can easily change it for another job or a later run, you can reference a filename indirectly. Use a FILENAME statement, the FILENAME function, or an appropriate operating system command to assign a fileref or nickname, to a file. [*] Note that you can assign a fileref to a SAS catalog that is an external file, or to an output device, as shown in the following table.

Table 39.2: Referencing External Files Indirectly

External File Task

Tool

Example

Assign a fileref to a file that contains input data.

FILENAME

filename mydata ' input-file ';

Assign a fileref to a file for output data.

FILENAME

filename myreport ' output-file ';

Assign a fileref to a file that contains program statements.

FILENAME

filename mypgm ' source-file ';

Assign a fileref to an output device.

FILENAME

filename myprinter < device-type >< host-options >;

Specify the file that contains input data.

INFILE

  data weight;    infile mydata;    input idno $ week1 week16;    loss=week1-week16;  

Specify the file that the PUT statement writes to.

FILE

  file myreport;       if loss ge 5 and loss le 9 then          put idno loss 'AWARD STATUS=3';       else if loss ge 10 and loss le 14 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 mypgm;

[*] In some operating environments, you can also use the command '&' to assign a fileref.




SAS 9.1.3 Language Reference. Concepts
SAS 9.1.3 Language Reference: Concepts, Third Edition, Volumes 1 and 2
ISBN: 1590478401
EAN: 2147483647
Year: 2004
Pages: 258

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