DATA Step, Macro, Functions and more

Macro statement %put and log

Reply
Occasional Contributor
Posts: 8

Macro statement %put and log

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.

SAS Employee
Posts: 26

Re: Macro statement %put and log

is the MPRINT option turned on?

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

options source source2 symbolgen mprint mlogic;

Jan

Super User
Posts: 5,082

Re: Macro statement %put and log

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


Occasional Contributor
Posts: 8

Re: Macro statement %put and log

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?

Regular Contributor
Posts: 195

Re: Macro statement %put and 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

Contributor
Posts: 60

Re: Macro statement %put and log

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.

Super User
Posts: 9,681

Re: Macro statement %put and log

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

Ask a Question
Discussion stats
  • 6 replies
  • 273 views
  • 0 likes
  • 6 in conversation