Hello Everyone,
I am looking at a code and trying to understand how the macro gets triggered. Program A has a %include that references program B. Program B has 3 macros in it. Nowhere in Program A or Program B do I see those 3 macros being referenced with %macro_name.
Based on what I understand, a macro gets executed when you use %macro_name to trigger it. I don't see the 3 macro names referenced in any program. How does the code trigger the 3 macros in this case? Please let me know if I am not clear.
Thank you!
They don't. You can create the template for the macro code as much as you like:
%macro XYZ ();
%mend XYZ;
But if nowhere in the code does: %XYZ (); appear then that macro does not get executed. There is not trigger to insert the macro code anywhere.
The macros would get compiled though so would be ready in that SAS session in case another program needed them.
Chances are, they are not executed. Perhaps the %INCLUDE statement was merely copied from another program that did actually use the macros. But other possibilities exist.
Another %INCLUDE statement might bring in code that executes %MACRO_NAME.
Another macro might execute, which executes %MACRO_NAME.
If it's a short-running program, you might just remove the %INCLUDE, run the program, and see what happens.
Good luck.
Also you may wanna look for any 'Call execute' statement which also could be used to invoke a macro program from a DATA step.
To check, add a statement to the macros in program B like %put 'Macro executed now';
Then look in the log for this message.
It may well be that the same macros or any statements that have the same effect are already executed in/from the autoexec.sas
Also consider using options mlogic to see when a macro is being executed and what it does.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.