Does anyone have a recommendation for how to loop through a series of variables in a SAS dataset which all need to be recoded the same way? For example, I am doing the following to recode the variable CF1:
DATA COGFLEX; SET COGFLEX;
SELECT(CF1);
WHEN ('1 Strongly Disagree') CF1=1;
WHEN ('2 Disagree') CF1=2;
WHEN ('3 Slightly Disagree') CF1=3;
WHEN ('4 Slightly Agree') CF1=4;
WHEN ('5 Agree') CF1=5;
WHEN ('6 Strongly Agree') CF1=6;
OTHERWISE CF1=.;
END;
RUN;
I want to do the same for variables CF2 through CF12. I am assuming there is a way to tell SAS to loop through these variables and perform the exact same transformation, but I haven't been able to figure out how to do that. Any help would be much appreciated.