BookmarkSubscribeRSS Feed
Aexor
Lapis Lazuli | Level 10

Hi All,

 

I have theoritical question , I might able to explain this with example. 

 

I have  3 macros macroA , macroB and macroC

 

execution of those is like shown below.

%macro macroA;

some Sas codes

%mend macroA;

 

%macro macroB;

  %macroA

Along with some Sas codes which may use output of macroA

%mend macroB;

 

%macro macroC;

some Sas codes

%mend macroC;

 

%macroB;

%macro C;

 

Now if want to call macroA How  can we do that?

 

Also if I am doing like this will this impact anything ?

 

%macro macroA;

some Sas codes

%mend macroA;

 

%macroA;      /* caling this outside macroB*/

 

%macro macroB;

Along with some Sas codes which may use output of macroA

%mend macroB;

 

%macro macroC;

some Sas codes

%mend macroC;

 

%macroB;

%macro C;

 

 

 

 

2 REPLIES 2
sbxkoenk
SAS Super FREQ

Hello,

 

Are you running into a problem somewhere?

 

You just need to make sure that a macro is defined and compiled before it is called.

%MACRO ABC; _some_statements_; %MEND;

... is defining macro ABC. (%MEND can be read as MacroEND by the way).

When you submit this macro definition, the macro, named ABC, then gets compiled and stored in a catalog.

 

You can call a macro within another macro.
Make sure to %GLOBAL some macro variables if you need them outside the macro where they are created.

Data sets created in a first macro can perfectly be used and read and processed in a subsequent macro.

Data sets are NOT local to the macro where they are created.

 

Macro definitions have to be re-run in every SAS session (because the compiled version is stored in WORK library).

If you want to avoid that, you can use the "stored compiled macro facility" (sasmstore) or the autocall library facility.

 

Not sure what your problem is.

 

Koen

PaigeMiller
Diamond | Level 26

Agreeing with @sbxkoenk — not sure what the problem is here.

 

However, @Aexor, you could try it both ways and see what happens. I'm not sure why you haven't done that already.

--
Paige Miller

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 398 views
  • 2 likes
  • 3 in conversation