Chapter Contents


SAS Macro Language: Reference

Defining and Calling Macros

Macros are compiled programs that you can invoke (or 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 general form of a macro definition is

%MACRO macro-name;
%MEND <macro_name>;

where 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


A later section illustrates calling a macro. The following section illustrates how the macro processor compiles and stores a macro definition.

Chapter Contents



Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.