DATA Step, Macro, Functions and more

Can you trigger a macro by using a %include ??

Regular Contributor
Posts: 173

Can you trigger a macro by using a %include ??

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!

Super User
Super User
Posts: 7,401

Re: Can you trigger a macro by using a %include ??

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.

Super User
Posts: 10,500

Re: Can you trigger a macro by using a %include ??

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

Super User
Posts: 5,082

Re: Can you trigger a macro by using a %include ??

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.

New Contributor
Posts: 2

Re: Can you trigger a macro by using a %include ??

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

Super User
Posts: 6,938

Re: Can you trigger a macro by using a %include ??

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

Also consider using options mlogic to see when a macro is being executed and what it does.

Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 5 replies
  • 6 in conversation