This document
is the macro facility language reference for SAS. It is a reference
for the SAS macro language processor and defines the SAS macro language
elements. This section introduces the SAS macro facility using simple
examples and explanation.
The
macro
facility is a tool for extending and customizing SAS
and for reducing the amount of text that you must enter to do common
tasks. The macro facility enables you to assign a name to character
strings or groups of SAS programming statements. You can work with
the names that you created rather than with the text itself.
The SAS macro language is a string based language.
It does not support the use of hexadecimal character constants.
Note: The SAS macro language does
not support using hexadecimal values to specify non-printable characters.
When you use a macro
facility name in a SAS program or from a command prompt, the macro
facility generates SAS statements and commands as needed. The rest
of SAS receives those statements and uses them in the same way it
uses the ones that you enter in the standard manner.
The macro facility has
two components:
is the portion of SAS
that does the work
is the syntax that
you use to communicate with the macro processor
When SAS compiles
program text, two delimiters trigger macro processor activity:
The text
substitution produced by the macro processor is completed before the
program text is compiled and executed. The macro facility uses statements
and functions that resemble the statements and functions that you
use in the DATA step. An important difference, however, is that macro
language elements can enable only text substitution and are not present
during program or command execution.
Note: Three SAS
statements begin with a % that are not part of the macro facility.
These elements are the %INCLUDE, %LIST, and %RUN statements in
SAS Statements: Reference
The following graphic
explains the syntax used in this document: