BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jonatan_velarde
Lapis Lazuli | Level 10

HI friends:

 

I have this data set:

 

data have;

input Questions sex yes no;

cards;

Question_1 male 2 5

Question_2 male 3 4

Question_3 male 5 1

;

and i have to obtain this table:

 

Question Sex yes_no
1 male 1
1 male 1
1 male 0
1 male 0
1 male 0
1 male 0
1 male 0
2 male 1
2 male 1
2 male 1
2 male 0
2 male 0
2 male 0
2 male 0
3 male 1
3 male 1
3 male 1
3 male 1
3 male 1
3 male 0

 

 

need to be notice that 0 means NO and 1 means YES, from the origin dataset

 

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
data want;
set have;

Question = input(compress(questions, , 'kd'), 8.);

do i=1 to yes;
yes_no=1;
output;
end;

do i=1 to no;
yes_no=0;
output;
end;

run;

View solution in original post

2 REPLIES 2
Reeza
Super User
data want;
set have;

Question = input(compress(questions, , 'kd'), 8.);

do i=1 to yes;
yes_no=1;
output;
end;

do i=1 to no;
yes_no=0;
output;
end;

run;
ballardw
Super User

Be aware that you cannot do any meaningful analysis of combinations of the questions such as "males that answered yes to questions 1 and 2" with data from a summary like this..

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 529 views
  • 0 likes
  • 3 in conversation