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;
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
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.