BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
buechler66
Barite | Level 11
Thanks so much for your time.
Kurt_Bremser
Super User

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.

Astounding
PROC Star

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;

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 17 replies
  • 3142 views
  • 6 likes
  • 5 in conversation