I have a data set consists of 60 variables and 100 observations. The observations for each question can take one of the following characters (a, b, c, d, e). I want to convert them to numeric, so I tried to use Do loop, but for some reason, it didn't run. Here is my SAS code:
DATA nXYZ;
set data XYZ;
array nQ {60} Q1-Q60;
do i = 1 to 60;
if Q[i] = 'a' then nQ[i] = 5;
else if Q[i] = 'b' then nQ[i] = 4;
else if Q[i] = 'c' then nQ[i] = 3;
else if Q[i] = 'd' then nQ[i] = 2;
else if Q[i] = 'e' then nQ[i] = 1;
end;
RUN;
I was wondering what things I did wrong. Your help is appreciated.
proc format. It exists to address this sort of task. - Jeff