Thank you all for your replies, suggestion, explanation. This is really quality place to be with. A bit more background Mission: trying to convert a long list of Excel tabs to SAS code. The spreadsheet has tricky business logic that recently starts to behave unstably .. So there is no data throughput challenge So long list of macros have to be generated so references across Excel tabs become macro calling within one big piece of SAS code. Initially, the code runs as some here have suggested (no do loop whatsoever) " data _null_; call symputx(cats('bal_y1',kx,'_ll',ll,'eg'); call symputx(cats('bal_y2',kx,'_k4',k4,'g'); ....; run; " Some blocks like this have 64 rows. Some 120.... The example I provided was 4 year loop, greatly simplified. Naturally, after the primitive coding allowed the SAS results to have matched with Excel figures, need to zip up the rows to make it, among other things, more readable. Primitive was not hard by the way; one can use Excel easily to populate hundreds of rows of names due to their regular expressions. Intriguing, though, (not that I don't accept the argument "you are not supposed to create macro inside data step like this..."), is that (not insisting), the (now notorious) original piece as posted ran fine Thursday and Friday, and stopped >=Saturday 6/11th. "data _null; set &um_bal (where=(kx in (0,12,24,36))); kx=(kx+12)/12; %macro k ; %do kxy =1 %to 4; ..... %mend k; %k; run; " as if it was the piece Reeza wrote and replied. I understand all the explanations ... If the original piece was so outrageous "not supposed to", why it ran for two days without warning (>50 times) resulting in correct calculation.... And NOW it simply said in the log the macro variable is not resolved. 5 . Each set of macro variables created block by block have to be 1. global. 2. have to stay with the data step ( well, point well taken that WITH the data step means NOT to put WITHIN the data step, although Thursday, Friday's success told me "well, I can. sometimes"). So I need to do some re-planning. I understand some suggestions because I used to build many macros, put them together in one big piece. Use one %include. Then call as I want, very floating, portable. Unfortunately, in this context, THE macro has to sit with the step. (OK, not WITHIN, agreed) , due to requirement embedded with target Excel spreadsheet tabs.... or at least not floating portable manners 6. No, not trying to check if 0, 12, 24,36 are in the data set. Not a matching exercise. + I am afraid I cannot provide more details, confidentiality..... I already spent a lot of time purging my original posted piece, but I think the original piece was sufficient for Q & A. Greatly appreciate. Thanks.
... View more