Good afternoon all, I have taken a lot of the advice offered here and here is the final result (of this stage). Macro code follows (apologies for formatting) %macro Step0(lib,debug=1); /* Get MEMNAMES into macro variables */ proc sql noprint; select memname into :dsname1 - :dsname99999 from dictionary.tables where libname =%upcase("&lib") ; quit; %local tablecount ; %let tablecount= &sqlobs ; %do i=1 %to &tablecount; proc sql feedback; select upcase(name) into :cname1 - :cname999999 from &lib..%upcase(&&dsname&i) ; quit; %local Colcount ; %let Colcount= &sqlobs ; %do k=1 %to &colcount; proc sql feedback; select count(name) into :countresult1 from &lib..%upcase(&&dsname&i) where %upcase(name) = %upcase("&&cname&k") ; quit; proc sql; Update Ruser.Test /*make this a parameter? */ Set Counts = &countresult1 where %upcase(name) = "&&cname&k" ; quit; %end; %*If in debug mode, dump local macro vars to log; %if &debug=1 %then %do; %printMacVars(scope = Step0) %end; %end; %Mend Step0; %Step0(RUSER, debug = 1); Lessons learned: 1) there a lot of useful bits in SAS I am not aware of (example:&sqlobs) I had the right ideas through this little project, but...not quite the right approach. 2) scope matters - it helps to make sure you are using the correct loop variable at all times (corollary: don't get to clever, you'll outwit yourself) 3)if it looks to complicated, you are likely doing it wrong. I thank everyone for their assistance and explanations. I have a lot to chew on with all of the replies in this topic, and a lot to learn. Thanks again!
... View more