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.
Referencing External Files Indirectly
|
|
|
Assign a fileref to
a file that contains input data.
|
|
filename mydata 'input-file';
|
Assign a fileref to
a file for output data.
|
|
filename myreport 'output-file';
|
Assign a fileref to
a file that contains program statements.
|
|
filename mypgm 'source-file';
|
Assign a fileref to
an output device.
|
|
filename myprinter <device-type>
<host-options>;
|
Specify the file that
contains input data.
|
|
data weight;
infile mydata;
input idno $ week1 week16;
loss=week1-week16;
|
Specify the file that
the PUT statement writes to.
|
|
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.
|
|
|