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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.