I have a 10 item questionnaire in which all 10 questions have the same answer choices: “never”, ‘almost never”, “sometime”, “fairly often” and “very often”. I want to change the values in the dataset from text characters to number characters ranging from 0 to 4. However, I do not want to write 500 if/then statements. I need a code that searches all 10 questions finds the specified “text” and changes it to the corresponding number value.
I tried to do arrays and do over statements but I don’t know how to get the code just right. How can I modify the code below to produce what I want? Thank you.
array b pss_oppera_q1-pss_oppera_q10;
do over b;
if b = "Never" then b = 0;
if b = "Almost never" then b = 1;
if b = "Sometimes" then b = 2;
if b = "Fairly often" then b = 3;
if b = "Very often" then b = 4;
end;
... View more