Mike, I can be aware of two problems in your code: 1. Using %do %while (&var_name ne); when 'var_name' is not available until next step. %do %while evaluates expression at the top of the loop, instead, %do %until evaluates on the bottom. 2. Misused %scan(). "" should be removed from %scan(&varlist,&i,""); So the working code looks like: %let varlist=yy zz aa; %MACRO test(varlist=); %let i=1; %do %until (&var_name eq); %let var_name=%scan(&varlist,&i); %put &var_name; %let i=%eval(&i+1); %end; %mend; %test(varlist=&varlist) As an alternative, you can also try: %MACRO test(varlist=); %do i=1 %to %sysfunc(countw(&varlist)); %let var_name&i=%scan(&varlist,&i); %put &&var_name&i; %end; %mend; Kindly Regards, Haikuo
... View more