Chapter Contents

Previous

Next
SAS Macro Language: Reference

How the Macro Processor Compiles a Macro Definition

When you submit a SAS program, the contents of the program goes to an area of memory called the input stack. The example program in Macro APP in the Input Stack contains a macro definition, a macro call and a PROC PRINT step. This section illustrates how the macro definition in the example program is compiled and stored.

Macro APP in the Input Stack

[IMAGE]

Using the same process described in Chapter 2, "SAS Programs and Macro Processing," the word scanner begins tokenizing the program. When the word scanner detects % followed by a non-blank character in the first token, it triggers the macro processor. The macro processor examines the token and recognizes the beginning of a macro definition. The macro processor pulls tokens from the input stack and compiles until the %MEND statement terminates the macro definition (Macro APP in the Input Stack).

During macro compilation, the macro processor

If the macro processor detects a syntax error while compiling the macro, the macro processor checks the syntax in the rest of the macro and issues messages for any additional errors it finds. However, the macro processor does not store the macro for execution. A macro that the macro processor compiles but does not store is called a dummy macro.

Macro APP in the Input Stack

[IMAGE]

In this example, the macro definition is compiled and stored sucessfully (Figure 4.3). For the sake of illustration, the compiled APP macro looks like the original macro definition that was in the input stack. The entry would actually contain compiled macro instructions with constant text. The constant text in this example is underlined.

The Compiled Macro APP

[IMAGE]


Chapter Contents

Previous

Next

Top of Page

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