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.
*
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);
*
SAS creates a file that is named with the appropriate extension for your operating environment.
Referencing External Files with Other Access
Methods
You can assign filerefs to external files that you access with the following FILENAME
access methods:
CATALOG
DATAURL
FTP
Hadoop
SFTP
TCP/IP SOCKET
URL
WebDAV
ZIP
Examples of how to use each method are shown in the following table:
764 Chapter 39
External Files
Table 39.4 Referencing External Files with Other Access Methods
External File
Task Tool Example
Assign a fileref
to a SAS catalog
that is an
aggregate
storage location.
FILENAME with
CATALOG
specifier
filename mycat catalog 'catalog'
<catalog-options>;
Assign a fileref
to an external
file accessed by
a data URL.
FILENAME with
DATAURL
specifier
filename myfile dataurl 'external-file'
<dataurl-options>;
Assign a fileref
to an external
file accessed
with FTP.
FILENAME with
FTP specifier
filename myfile FTP 'external-file'
<ftp-options>;
Assign a fileref
to an external
file accessed on
a Hadoop
Distributed File
System.
FILENAME with
Hadoop specifier
filename myfile hadoop 'external-file'
<hadoop-options>;
Assign a fileref
to an external
file accessed
with SFTP.
FILENAME with
SFTP specifier
filename myfile SFTP 'external-file'
<sftp-options>;
Assign a fileref
to an external
file accessed by
TCP/IP
SOCKET in
either client or
server mode.
FILENAME with
SOCKET
specifier
filename myfile SOCKET 'hostname: portno'
<tcpip-options>;
or
filename myfile SOCKET ':portno' SERVER
<tcpip-options>;
Assign a fileref
to an external
file accessed by
URL.
FILENAME with
URL specifier
filename myfile URL 'external-file'
<url-options>;
Assign a fileref
to an external
file accessed on
a WebDAV
server.
FILENAME with
WEBDAV
specifier
filename myfile WEBDAV 'external-file'
<webdav-options>;
Assign a fileref
to a ZIP file
accessed by
using Zlib
services.
FILENAME with
ZIP specifier
filename myfile ZIP 'external-file'
<zip-options>;
Referencing External Files with Other Access Methods 765

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.