Chapter Contents |
Previous |
Next |
SAS Macro Language: Reference |
This is the macro facility language reference for the SAS System. It is a reference for the SAS macro language processor and defines the SAS macro language elements. This chapter introduces the SAS macro facility using simple examples and explanation.
The macro facility is a tool for extending and customizing the SAS System and for reducing the amount of text you must enter to do common tasks. The macro facility allows you to assign a name to character strings or groups of SAS programming statements. From that point on, you can work with the names rather than with the text itself.
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 the SAS System receives those statements and uses them in the same way it uses the ones you enter in the standard manner.
The macro facility has two components:
the macro processor | is the portion of the SAS System that does the work. |
the macro language | is the syntax that you use to communicate with the macro processor. |
When the SAS System compiles program text, two delimiters trigger macro processor activity:
&name | refers to a macro variable. Replacing Text Strings Using Macro Variables explains how to create a macro variable. The form &name is called a macro variable reference. |
%name | refers to a macro. Generating SAS Code Using Macros explains how to create a macro. |
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 those that you use in the DATA step; however, an important difference is that macro language elements can only trigger 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.
These statements are documented in your base SAS documentation.
This chapter shows you how to define and use macro variables and macros. In each topic, you are directed to another chapter that covers the material in detail.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.