BookmarkSubscribeRSS Feed
snowflake
Fluorite | Level 6

Dear all

I have got a question concerning the macro statement %put. Is there any explanation why the statement %put is not written to the log, if executed from within a macro.

What I don´t understand is the following example:

options mprint ;

%macro test(tt=);

     %put &tt;

%mend;

%test(tt=abc);

%put test;

The log shows the following

469  options mprint ;

470

471  %macro test(tt=);

472  %put &tt;

473  %mend;

474  %test(tt=abc);

abc

475  %test(tt=efg);

efg

476  %put test;

test

Why am I not seeing the statments that generated abc and efg whereas the %put test Statement outside the macro is shown. I had expected to get something like this in the log:

MPRINT(test) %put &tt;

Can anyone explain me that?

Thanks a lot in advance

Regards Kathy

:

Why doesn´t the log show the statements generated by the macro call (e.g.

6 REPLIES 6
jwsquillace
SAS Employee

is the MPRINT option turned on?

Here's the option statement I use when debugging macro code:

options source source2 symbolgen mprint mlogic;

Jan

Astounding
PROC Star

Per the documentation, MPRINT displays the generated SAS language statements.  It doesn't display generated macro language statements.


snowflake
Fluorite | Level 6

Thanks for your replies.

: Yes mprint is on.

: But why it puts a note to the log if used outside a macro?

Is there a way I can get the %put statement shown in the log?

UrvishShah
Fluorite | Level 6

As per documentation, MPRINT will generate all the statements which has been sent to appropriate compiler...And if MPRINT is turnoff you can not see the statements which has been sent to different compilers during Macro Processing...

%PUT outside the macro prints the %PUT statement because it is not within the MACRO...it's outside the MACRO...

If you wish to print %PUT statement during macro processing than use the following code...

%macro test(macvar =);

   %put MPRINT(&SYSMACRONAME): %nrstr(%put) %nrstr(&macvar.);

   %put &macvar.

%mend;

%test(macvar = ABC);

-Urvish

Sudhakar_A
Calcite | Level 5

Mprint only print the datastep or proc step execution statements in to SAS log, Mlogic will print the %IF or any logical statements used inside the macro. %put execution will not be printed as you expect.

Ksharp
Super User

How about put it manually ?

%macro test(tt=);
     %put %nrstr(%put &tt) &tt;
%mend;

%test(tt=abc);

%put test;

options mprint mlogic symbolgen;

%macro test(tt=);

     %put &tt;

%mend;

%test(tt=abc);

%put test;

Ksharp

Message was edited by: xia keshan

sas-innovate-2024.png

Today is the last day to save with the early bird rate! Register today for just $695 - $100 off the standard rate.

 

Plus, pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1031 views
  • 0 likes
  • 6 in conversation