SAS provides another method of accessing files in addition
to assigning a libref with the LIBNAME statement or using the
New Library window.
To use this method, enclose the filename, or the filename and path,
in single quotation marks.
For example, in a directory-based
system, if you want to create a data set named MYDATA in your default
directory, that is, in the directory that you are running SAS in,
you can write the following line of code:
data 'mydata';
SAS creates the data
set and remembers its location for the duration of the SAS session.
If you omit the single
quotation marks, SAS creates the data set MYDATA in the temporary
WORK subdirectory, named WORK.MYDATA:
data mydata;
If you want to create
a data set named MYDATA in a library other than the directory in which
you are running SAS, enclose the entire path in quotation marks, following
the naming conventions of your operating environment. For example,
the following DATA step creates a data set named FOO in the directory
C:\sasrun\mydata.
data 'c:\sasrun\mydata\foo';
This method of accessing
files works on all operating environments and in most contexts where
a
libref.data-set-name is accepted
as a SAS data set. Most data set options can be specified with a
quoted name.
You cannot use quoted
names for the following:
-
-
-
contexts that do not accept a libref,
such as the SELECT statement of PROC COPY and most PROC DATASETS statements
-
-
DATA step stored programs, or SAS
views
-
SAS Component Language (SCL) open
function
The following table
shows some examples of DATA statements that access SAS data files
without using a libref.
Example DATA Statements That Access SAS Files without Using
a Libref
|
|
|
data 'c:\root\mystuff\sasstuff\work\myfile';
|
|
data '/u/root/mystuff/sastuff/work/myfile';
|
|
data 'user489.mystuff.saslib(member1)';
/* bound SAS library */
data '/mystuff/sasstuff/work/myfile';
/* UNIX file system library */
|
|
data 'filename filetype filemode';
|