Macro Language Dictionary

MPRINT System Option



Controls whether SAS statements generated by macro execution are traced for debugging
Type: System option
Valid in:

Configuration file

OPTIONS window

OPTIONS statement

SAS invocation

Default: NOMPRINT
PROC OPTIONS GROUP= MACRO
See also: MFILE System Option

Syntax
Details
Examples
Example 1: Tracing Generation of SAS Statements
Example 2: Directing MPRINT Output to an External File

Syntax

MPRINT | NOMPRINT

MPRINT

displays the SAS statements that are generated by macro execution. This is 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. Each statement ends with a semicolon.

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)

Executing this program writes this MPRINT output 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';

space
Previous Page | Next Page | Top of Page