You can use the SET system option to define a SAS variable. For example, if you
store your permanent SAS data sets
in the C:\SAS\MYSASDATA folder, you can use the following SET option in the SAS command
when you start SAS or in your SAS
configuration file to assign the variable TEST to this SAS library:
-set test c:\sas\mysasdata
When you assign a variable, SAS does not resolve the reference until the variable
name is actually used. For example, if the TEST variable is defined in your SAS
configuration file, the variable TEST is not resolved until it is referenced by SAS.
Therefore, if
you make a mistake in your SET option specification, such as misspelling a folder
name, you do not receive an error message until you use the variable in a SAS statement.
Because Windows filenames can contain spaces or single quotation marks as part of
their names, you should enclose the name of the physical path in double quotation
marks when specifying the SET option. If you use the SET option in an OPTIONS statement,
you must use quotation marks around the
filename. For complete syntax of the SET system option, see
SET System Option: Windows .
Any variable name that you use as a value for a system option in your SAS configuration
file must be defined as a variable before it is used. For example, the following
SET
option must appear before the SASUSER option that uses the variable TEST:
-set test "d:\mysasdir"
-sasuser "!test"
In the following example,
variables are used with concatenated libraries:
-set dir1 "c:\sas\base\sashelp"
-set dir2 "d:\sas\stat\sashelp"
-sashelp (!dir1 !dir2)
Note that when you reference variables in your SAS configuration file or in a LIBNAME
statement in your SAS programs, you must precede the variable name
with an exclamation point (!).
It is recommended that you use the SET system option in your SAS configuration file
if you invoke SAS through a Windows shortcut.