I typically do something like the following. But as BallardW has indicated, your results don't match your question.
data have;
input Slno Q1_1 Q1_2 Q1_3;
cards;
1 1 0 1
2 0 . 0
3 1 1 0
4 1 . 0
5 1 1 1
6 0 . 1
7 0 1 1
8 1 0 1
9 1 . 1
10 1 0 0
;
run;
data step1;
set have;
array ques(3) q1_1 q1_2 q1_3;
do i=1 to dim(ques);
response=ques(i);
question=vname(ques(i));
output;
end;
run;
proc means data=step1 n sum mean;
class question;
var response;
run;
proc freq data=step1;
table question*response/list missing;
run;
hi Reeza,
The solution array given by you worked perfectly but unfortunately is not the solution as the observations are increasing as a result of the array,
For example i have 30 respondents. when i am using an array it increases to 90 respondents.
I am attaching a sample files for your perusal. Request you to kindly go through the file and suggest a soultion.
Thanks,
Saikiran
It will increase to 90 observations, # of respondents *# of questions - in this case, 30 * 3= 90.
You basically have Person*Question level data instead of person level data now.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.