Note: Database management system (DBMS) files are a special category of files that
can be read with SAS/ACCESS software. For more information about DBMS
files, see Chapter 33, “About SAS/ACCESS Software,” on page 709 and the
SAS/ACCESS documentation for your DBMS.
Operating Environment Information
Using external files with your SAS jobs entails significant operating-environment-
specific information. For more information, see the SAS documentation for your
operating environment.
Referencing External Files Directly
To reference a file directly in a SAS statement or command, specify in quotation marks
its physical name. This is the name by which the operating environment recognizes it, as
shown in the following table:
Table 39.1 Referencing External Files Directly
External File Task Tool Example
Specify the file that contains
input data.
INFILE
data weight;
infile 'input-file';
input idno $ week1 week16;
loss=week1-week16;
Identify the file that the PUT
statement writes to.
FILE
file 'output-file ';
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 'source-file';
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.
1
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.
1
In some operating environments, you can also use the command '&' to assign a fileref.
762 Chapter 39 External Files

Get SAS 9.4 Language Reference, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.