BookmarkSubscribeRSS Feed
KevinC_
Fluorite | Level 6

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!

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

ballardw
Super User

The macros would get compiled though so would be ready in that SAS session in case another program needed them.

Astounding
PROC Star

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.

vmurali
Calcite | Level 5

Also you may wanna look for any 'Call execute' statement which also could be used to invoke a macro program from a DATA step.

Kurt_Bremser
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 5 replies
  • 1172 views
  • 0 likes
  • 6 in conversation