Wednesday, October 18, 2006

Debugging Complex Macros

You can write code generated by macros to an external file. Since you can see the code that is generated, this technique can be useful for debugging complex macros.

The MPRINT system option writes to the SAS log each SAS statement generated by a macro. Using the MPRINT option is recommended when you suspect your bug lies in code that is generated in a manner you did not expect.

The MFILE option specifies whether MPRINT output is directed to an external file.

Using the technique described below, you can redirect the SAS statements generated by a macro to an external file instead of to the log.
First, include MFILE and MPRINT in your options statement:
options mfile mprint;
Next, include a fileref for MPRINT:
filename mprint '/home/mydir/';

The SAS code generated by your macro(s) will be written to You can then submit to resolve any problems.
Click here to learn more about debugging macros.


Post a Comment

<< Home