General Macro Debugging Information
Developing Macros in a Layered Approach
Because the macro facility is such a powerful tool, it is also complex, and debugging
large macro applications can be extremely time-consuming and frustrating. Therefore, it
makes sense to develop your macro application in a way that minimizes the errors. This
makes the errors that do occur as easy as possible to find and fix. The first step is to
understand what type of errors can occur and when they manifest themselves. Then,
develop your macros using a modular, layered approach. Finally, use some built-in tools
such as system options, automatic macro variables, and the %PUT statement to diagnose
errors.
Note: To receive certain important warning messages about unresolved macro names
and macro variables, be sure the “SERROR System Option” on page 384 and
“MERROR System Option” on page 365 are in effect. For more information, see
“System Options for Macros” on page 353.
Encountering Errors
When the word scanner processes a program and finds a token in the form of & or %, it
triggers the macro processor to examine the name token that follows the
& or %.
Depending on the token, the macro processor initiates one of the following activities:
macro variable resolution
macro open code processing
macro compilation
macro execution
An error can occur during any one of these stages. For example, if you misspell a macro
function name or omit a necessary semicolon, that is a syntax error during compilation.
Syntax errors occur when program statements do not conform to the rules of the macro
language. Or, you might refer to a variable out of scope, causing a macro variable
resolution error. Execution errors (also called semantic errors) are usually errors in
program logic. They can occur, for example, when the text generated by the macro has
faulty logic (statements not executed in the right order or in the way you expect).
Of course, even if your macro code is perfect, that does not guarantee that you will not
encounter errors caused by plain SAS code. For example, you might encounter the
following:
a libref that is not defined
a syntax error in open code (that is, outside of a macro definition)
a typographical error in the code that your macro generates
Typically, error messages with numbers are plain SAS code error messages. Error
messages generated by the macro processor do not have numbers.
122 Chapter 10 Macro Facility Error Messages and Debugging
..................Content has been hidden....................

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