Chapter 4
Macro Processing
Macro Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Defining and Calling Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
How the Macro Processor Compiles a Macro Definition . . . . . . . . . . . . . . . . . . . . . 40
How the Macro Processor Executes a Compiled Macro . . . . . . . . . . . . . . . . . . . . . . 42
Summary of Macro Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Macro Processing
This section describes macro processing and shows the typical pattern that SAS follows
to process a program containing macro elements. For most macro programming, you do
not need this level of detail. It is provided to help you understand what is going on
behind the scenes.
Defining and Calling Macros
Macros are compiled programs that you can call in a submitted SAS program or from a
SAS command prompt. Like macro variables, you generally use macros to generate text.
However, macros provide additional capabilities:
Macros can contain programming statements that enable you to control how and
when text is generated.
Macros can accept parameters. You can write generic macros that can serve a
number of uses.
To compile a macro, you must submit a macro definition. The following is the general
form of a macro definition:
%MACRO macro_name;
<macro_text>
%MEND <macro_name>;
macro_name is a unique SAS name that identifies the macro and macro_text is any
combination of macro statements, macro calls, text expressions, or constant text.
39
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset