07-20-2014 10:29 AM
I am a new learner of SAS, this maybe a easy stuff for you.
my dataset look like this
ID Q1 Q2 Q3 Q4 Q5
1 NA Y N N Y
2 Y Y N NA NA
3 N N Y Y N
and I want to make the dataset into the following way
ID Q1 Q2 Q3 Q4 Q5 Yes_question
1 NA Y N N Y Q2 Q5
2 Y Y N NA NA Q1 Q2
3 N N Y Y N Q3 Q4
I have tried the following code
array yes(5) Q1--Q5;
do i = 1 to 5;
if yes(i)="Y" then yes_question=cat(yes_question2," ",vname(yes(i)));
But yes_question2 keeps equal to blanks and I can only get the result of blank+last Yes question.
Any simple code to make this possible?
Thanks for the help.
07-20-2014 11:25 AM
CAT() function does not trim so you are essentially reassigning the empty value in YES_QUESTION to itself.