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.
is the MPRINT option turned on?
Here's the option statement I use when debugging macro code:
options source source2 symbolgen mprint mlogic;
Jan
Per the documentation, MPRINT displays the generated SAS language statements. It doesn't display generated macro language statements.
Thanks for your replies.
jwsquillace: Yes mprint is on.
Astounding: 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?
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
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.
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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.