The SAS macro facility
is a tool for extending and customizing SAS. It also reduces the amount
of program code that you enter to perform common tasks. The macro
facility has its own language, which enables you to package small
or large amounts of text into units that are assigned names called macro
variables. After a macro variable is created, you can
insert the text into your code simply by referencing the macro variable
by its name.
SAS macro variables
enable you to substitute text in your SAS programs. Macro variables
can also provide the following information:
When you reference a
macro variable in a SAS program, SAS replaces the reference with the
text value that has been assigned to that macro variable. By substituting
text into the program, SAS macro variables make your programs more
reusable and dynamic.
There are two types
of macro variables:
-
automatic macro variables, which
are provided by SAS
-
user-defined macro variables, whose
values you create and define
Whether automatic or
user-defined, a macro variable is independent of a SAS data set and
contains one text string value that remains constant until you change
it. The value of a macro variable is substituted into your program
wherever the macro variable is referenced.
Macro variables are
stored in the global symbol table that makes the values available
in your SAS session.
Macro variables can
be defined and referenced anywhere in a SAS program except within
the data lines of a DATALINES statement.