Desktop productivity for business analysts and programmers

Call include statement within Macro if/else if

Occasional Contributor
Posts: 7

Call include statement within Macro if/else if

Hey all,

I am trying to call a different include statement inside of a macro, but having the include different based on if a different macro is selected


%macro DDL;

%if &upd = 2 or &upd = 4 or &upd = 5 %then %do;

  %include "/test/&";


%else %do;

  %include "/test/&";


%mend DDL;


Inside each of those is a different macro that needs to be used in a proc sql statement, but when I put this logic in my program is not reading the macor &Query

But when I had it just this it would work: %include "/test/&";

Not sure it's including it from the macro.. any thoughts?


Super User
Posts: 13,913

Re: Call include statement within Macro if/else if

Posted in reply to Bensansing

Unless those include files have identically named macros (and nothing else) with different behavior I would suggest you are spending a lot of time for not much reward. And if you do have the same named macro in each that is generally not a good idea. If they do different things they should have a different name.

Since compiling macros takes relatively few processes, include all of the macro source code at the start of the job, or investigate AUTOCALL macro libraries.

Are you getting errors? What value(s) of UPD that is causing the problem?

Have you run this with OPTIONS MPRINT SOURCE2;

Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation