Keep in mind that the macro language knows only two scopes: global and local.
If you define macro B within macro A, variable X that is present in A will be in the local table of A, but not in the local table of B. If you now call execute a macro with single quotes, the execution of the macro is postponed and the expected variable will not be present.
Defining a macro within another macro only means that the inner macro is compiled every time the outer macro executes, creating unnecessary overhead. Nesting macro calls is a different thing and can make sense, but most of the time complex macro calling is unnecessary and a violation of the KISS principle that makes code hard to understand and brittle.
Based on some of your follow-up responses, here is an approach to consider.
proc sql;
select distinct(zip5) into : allzips separated by ' ' from sampledzips;
quit;
%macro loopthru;
%local i rule_order zip5;
%do i = 1 %to %sysfunc(countw(&allzips));
%let zip5 = %scan(&allzips, &i);
%do rule_order=1 %to 9;
%put &zip5 &rule_order;
%** Possibly do something else at this point as well;
%end;
%end;
%mend loopthru;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.