To be honest, if your code is just a series of if statements over a set of variables why not do: proc sql; select distinct NAME into :LIST from SASHELP.VCOLUMN where LIBNAME="WORK" and MEMNAME="ABC"; select count(distinct NAME) into :TOT from SASHELP.VCOLUMN where LIBNAME="WORK" and MEMNAME="ABC"; quit; data want; set have; array to_process{&TO_PROCESS.} $20. (&LIST.); array done{&TO_PROCESS.} 8.; do I=1 to &TO_PROCESS.; select(to_process{I}); when ('a') done{I}=1; when ('b') done{I}=0; otherwise; end; end; run; Note that this will give you a series of variables DONEx, having the numeric suffix after variable names is easier to deal with when talking about processing multiple columns (i.e. your example would be far easier if your variables were ORIG_VAR_x, then you would just define a range.
... View more