MPRINT System Option

Specifies whether SAS statements generated by macro execution are traced for debugging.
Valid in: Configuration fileOPTIONS window OPTIONS statementSAS invocation
PROC OPTIONS GROUP= MACRO

LOGCONTROL

Type: System option
Default: NOMPRINT
See: MFILE System Option and The SAS Log in SAS Language Reference: Concepts

Syntax

MPRINT | NOMPRINT

Required Arguments

MPRINT
displays the SAS statements that are generated by macro execution. The SAS statements are useful for debugging macros.
NOMPRINT
does not display SAS statements that are generated by macro execution.

Details

The MPRINT option displays the text generated by macro execution. Each SAS statement begins a new line. Each line of MPRINT output is identified with the prefix MPRINT(macro-name):, to identify the macro that generates the statement. Tokens that are separated by multiple spaces are printed with one intervening space.
You can direct MPRINT output to an external file by also using the MFILE option and assigning the fileref MPRINT to that file. For more information, see MFILE System Option.

Examples

Example 1: Tracing Generation of SAS Statements

In this example, MPRINT traces the SAS statements that are generated when the macros MKTITLE and RUNPLOT execute:
%macro mktitle(proc,data);
    title "%upcase(&proc) of %upcase(&data)";
%mend mktitle;
%macro runplot(ds);
   %if %sysprod(graph)=1 %then
      %do;
         %mktitle (gplot,&ds)
         proc gplot data=&ds;
            plot style*price
                / haxis=0 to 150000 by 50000;
         run;
         quit;
      %end;
   %else
      %do;
         %mktitle (plot,&ds)
         proc plot data=&ds;
            plot style*price;
         run;
         quit;
      %end;
%mend runplot;
options mprint;
%runplot(sasuser.houses)
When this program executes, this MPRINT output is written to the SAS log:
MPRINT(MKTITLE):   TITLE "GPLOT of SASUSER.HOUSES";
MPRINT(RUNPLOT):   PROC GPLOT DATA=SASUSER.HOUSES;
MPRINT(RUNPLOT):   PLOT STYLE*PRICE / HAXIS=0 TO 150000 BY 50000;
MPRINT(RUNPLOT):   RUN;
MPRINT(RUNPLOT):   QUIT;

Example 2: Directing MPRINT Output to an External File

Adding these statements before the macro call in the previous program sends the MPRINT output to the file DEBUGMAC when the SAS session ends.
options mfile mprint;
filename mprint 'debugmac';