BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ja5ya
Fluorite | Level 6

Hello, So I understand the MPRINTNEST enables the macro-nesting information to be written to the SAS log in the MPRINT output. It prints out each and every macro that has been nested within a particular macro.
But what if a particular macro has almost 10/11 levels of nested macros within, the log gets too cluttered and troubleshooting gets way tough. Is there any way we can print out the nested macros in our log for only the latest 3 macros or some particular values of macros?
Please help!

1 ACCEPTED SOLUTION

Accepted Solutions
Amir
PROC Star

In that case, have you considered some post-processing, by creating a utility to read the log and create another log file where the nests that you don't want are removed, as they should be identifiable by "MPRINT (MACRO_NAME)", e.g., from the documentation:

 

MPRINT(OUTER):   data _null_;
MPRINT(OUTER.INNER):   put
MPRINT(OUTER.INNER.INRMOST):   'This is the text of the PUT statement'
MPRINT(OUTER.INNER):  ;
MPRINT(OUTER):   run;
This is the text of the PUT statement
NOTE: DATA statement used (Total process time):
      real time           0.10 seconds
      cpu time            0.06 seconds

 

Kind regards,

Amir.

View solution in original post

7 REPLIES 7
SASKiwi
PROC Star

With all due respect, anyone who nests SAS macros 10 or 11 deep needs their head read.There are far better ways to structure macro code.

 

I've never found the need to go beyond two or three levels maximum. MPRINTNEST is fine for two levels which should be 99 percent of the time, and adequate for three levels.

Ja5ya
Fluorite | Level 6
Yes, you are correct. But, we have such macros to handle large datasets. So it cannot be changed. Just wanted to know if such options are available in SAS.
Tom
Super User Tom
Super User

@Ja5ya wrote:
Yes, you are correct. But, we have such macros to handle large datasets. So it cannot be changed. Just wanted to know if such options are available in SAS.

The size of the data has nothing to do with the complexity of the code that is needed to deal with it.

 

Either do not use the nested printing option. Or spend the time to change your code.

Amir
PROC Star

You could try editing your macro to switch off the option at the start then switch it on again at the end.

 

Alternatively, create a parameter in the macro that can be used to determine whether the option is on or off for the duration of the macro.

 

 

Kind regards,

Amir.

Ja5ya
Fluorite | Level 6
Thanks, Amir, for your response. I did try putting the option in the middle so as to bypass the main macro. But looks like it's all or nothing. The main source of the macro is always being printed in my logs regardless of the position of the option which is not what I'm looking for.
Thanks again,
Jaya
Amir
PROC Star

In that case, have you considered some post-processing, by creating a utility to read the log and create another log file where the nests that you don't want are removed, as they should be identifiable by "MPRINT (MACRO_NAME)", e.g., from the documentation:

 

MPRINT(OUTER):   data _null_;
MPRINT(OUTER.INNER):   put
MPRINT(OUTER.INNER.INRMOST):   'This is the text of the PUT statement'
MPRINT(OUTER.INNER):  ;
MPRINT(OUTER):   run;
This is the text of the PUT statement
NOTE: DATA statement used (Total process time):
      real time           0.10 seconds
      cpu time            0.06 seconds

 

Kind regards,

Amir.

Ja5ya
Fluorite | Level 6
Thanks, Amir! Looks like post-processing will only be the way.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 7 replies
  • 708 views
  • 0 likes
  • 4 in conversation