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!
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.
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 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.
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.
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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.