There's actually a much easier way to achieve your goal, without having to write multiple IF statements. Just store the var1-varn variables in an array, loop through each one to check for the value 1, then use the VNAME function to add that variable name to the concatenated list. Your code will look something like this, I've put in 2 options for the 'multi' variable, the first stores the results as a comma separated list, the 2nd puts double quotes around each value as per your code. data checkfile; set xxx.xxx; length multi $140; array vars{*} var1--varn; do i=1 to dim(vars); if vars{i}=1 then call catx(',',multi,vname(vars{i})); /* or */ if vars{i}=1 then call catx('',multi,quote(vname(vars{i}))); end; drop i; run;
... View more