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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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