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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 267 views
  • 2 likes
  • 3 in conversation