My advice: don't use commas in macro variable lists. You just open yourself to a world of headaches. Instead, store your list as a (non-comma) delimited list. If your list data contains spaces (eg. file paths on Windows), use some other delimiter. Then, use a helper macro, and add the commas at "run time" when you need them. I'm a huge fan of Richard Devenezia, and I encourage you to visit his macros website: SAS Macros - by Richard A. DeVenezia - In particular, download the %seplist macro. It makes it dead easy to switch between data step (space delimited) and SQL (comma delimited) lists. I've also attached a %loop macro which I wrote - there are various versions "out there". Remove the call to %parmv. If you have either of these macros compiled, your code then becomes: %let list=a b c; %put %seplist(&list); %put %seplist(&list,prefix=sum%str(%(), suffix=%str(%))); %macro code; %if &__iter__ gt 1 %then ,; sum(&word) %mend; %put %loop(&list); %let list=a list ^ containing spaces; %put %seplist(&list,indlm=^); %put %seplist(&list,indlm=^,prefix=sum%str(%(), suffix=%str(%))); %put %loop(&list,dlm=^); Output: 15 %let list=a b c; 16 17 %put %seplist(&list); a,b,c 18 %put %seplist(&list,prefix=sum%str(%(), suffix=%str(%))); sum(a),sum(b),sum(c) 19 20 %macro code; 21 %if &__iter__ gt 1 %then ,; 22 sum(&word) 23 %mend; 24 %put %loop(&list); sum(a) , sum(b) , sum(c) 25 26 %let list=a list ^ containing spaces; 27 %put %seplist(&list,indlm=^); a list,containing spaces 28 %put %seplist(&list,indlm=^,prefix=sum%str(%(), suffix=%str(%))); sum(a list),sum(containing spaces) 29 %put %loop(&list,dlm=^); sum(a list) , sum(containing spaces) Hope this helps...
... View more