BookmarkSubscribeRSS Feed
Reeza
Super User

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;

2 REPLIES 2
tadiboinak
Calcite | Level 5

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

Reeza
Super User

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.

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 431 views
  • 0 likes
  • 2 in conversation