Using SAS Files |
An environment variable can be used as a libref. The variable name must be in all uppercase characters, and the variable value must be the full pathname of the directory; that is, the name of the directory must begin with a slash.
Note: SAS on UNIX does not support the assignment of the User libref using the USER environment variable.
Suppose you want to use the library in /users/mydir/educ, and you want to refer to it with the EDUC environment variable. You can define the variable at two times:
Before you invoke SAS. See Defining Environment Variables in UNIX Environments. For example, in the Korn shell, you would use:
export EDUC=/users/mydir/educ
After you invoke SAS, you can use the X statement (see Executing Operating System Commands from Your SAS Session) and the SAS setenv command:
x setenv EDUC /users/mydir/educ;
You cannot specify an engine when you define a libref as an environment variable, so SAS determines which engine to use as described in Omitting Engine Names from the LIBNAME Statement.
After the libref is defined, you can use it to access data sets stored in the library:
proc print data=educ.class; run;
Note: If a variable and a libref have the same name, but refer to different libraries, SAS uses the libref.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.