Previous Page | Next Page

Macro Processing

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:

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.

When you submit a macro definition, the macro processor compiles the definition and produces a member in the session catalog. The member consists of compiled macro program statements and text. The distinction between compiled items and noncompiled (text) items is important for macro execution. Examples of text items include:

When you want to call the macro, you use the form

%macro_name.

Previous Page | Next Page | Top of Page