An environment variable can also be used as a libref. The variable name must be in all uppercase characters , and the variable value must be the full pathname of 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 via the USER environment variable. |
Suppose you want to use the data 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" on page 21. 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" on page 13) 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" on page 304.
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 files, SAS uses the libref. |