Previous Page | Next Page

Using SAS Files

Specifying Pathnames in UNIX Environments


Rules for Specifying Directory and Pathnames

Whether you specify a data filename directly in the various SAS statements, or you specify the library name in a LIBNAME statement and then refer to the libref, the same rules apply for specifying UNIX directory and file pathnames.

Specify directory and file pathnames in quotation marks. The level of specification depends on your current directory.


Example 1: Access a File That Is Not in the Current Directory

If /u/2007/budgets is not your current directory, then to access the data file named May, you must specify the entire pathname:

data '/u/2007/budgets/may'; 

If you wanted to use a libref, you would specify:

libname budgets '/u/2007/budgets'; 
data budgets.may;


Example 2: Access a File in the Current Directory

If /u/2007/budgets is your current directory, you could specify only the filenames:

data 'quarter1';
merge 'jan' 'feb' 'mar';
run;

Note:   If you omit the quotation marks, then SAS assumes that these data sets are stored in the Saswork directory.  [cautionend]

If you wanted to use a libref, you would specify:
libname budgets '.';
data budgets.quarter1;
merge budgets.jan budgets.feb budgets.mar;
run;


Valid Character Substitutions in Pathnames

You can use the character substitutions in the following table to specify pathnames.

Character Substitutions in Pathnames
Characters Meaning
~/ $HOME/

Can be used only at the beginning of a pathname.

~name/ name's home directory (taken from file /etc/passwd ). Can be used only at the beginning of a pathname.
!sasroot name of sasroot directory (see The !SASROOT Directory). Specified only at the beginning of a pathname.
. current working directory.
.. parent of current working directory.
$VARIABLE
environment variable VARIABLE.

Previous Page | Next Page | Top of Page