Chapter Contents |
Previous |
Next |
SAS Companion for UNIX Environments |
Whether you reference a file directly or indirectly,
you will need to specify its pathname in the appropriate statement. In most
cases, you must enclose the name in quotes. For example, the following INFILE
statement refers to the file
/users/pat/cars
:
infile '/users/pat/cars';The following FILE statement directs output to the specified terminal:
file '/dev/ttyp1';
The level of specification depends on your current directory. You can use the character substitutions shown in Character Substitutions in Pathnames to specify the pathname. You can also use wildcards as described in Using Wildcards in Pathnames (Input Only).
You can omit the quotes on a filename if
.dat
, and the %INCLUDE
statement assumes a file extension of
.sas
.
For example, if the current directory is
/users/mkt/report
and it includes file
qtr.sas
, you can reference
qtr.sas
in any of the following statements:
%include '/users/mkt/report/qtr.sas'; %include 'qtr.sas'; file 'qtr.sas';If there is no QTR fileref already defined, you can omit the quotes and the filename extension on the %INCLUDE statement:
%include qtr;
Using Wildcards in Pathnames (Input Only) |
* | matches one or more characters, except for the period at the beginning of filenames. |
? | matches any single character. |
[ ] | matches any single character from the set of characters defined within the brackets. You can specify a range of characters by specifying the starting character and ending character separated by a hyphen. |
The following example reads input from every file in
the current directory that begins with the string
wild
and ends with
.dat
:
filename wild 'wild*.dat'; data; infile wild; input; run;
The following example reads input from every file in every subdirectory of the current working directory:
filename subfiles '*/*'; data; infile subfiles; input; run;If new files are added to any of the subdirectories, they can be accessed with the
subfiles
fileref without changing the FILENAME statement.
You can also use wildcards in filenames, but not in directory names, when you use aggregate syntax:
filename curdir "."; data; infile curdir('wild*'); input; run;The period in the FILENAME statement refers to the current directory. See Character Substitutions in Pathnames for information on other characters substitutions available on UNIX.
The following statement associates the fileref
myref
with all files that begin
with alphabetic characters. Files beginning with numbers or other characters
such as the period or tilde are excluded.
filename myref '[a-zA-Z]*.dat';The following statement associates
myref
with any file beginning with
sales
(in either uppercase, lowercase, or mixed case) and a year between
1990 and 1999:
filename myref '[Ss][Aa][Ll][Ee][Ss]199[0-9].dat';
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.