Dear anyone
Given the single choice answer in q1 (a-d) repondents get to answer q2a - q2d,(single choice, a - e) as shown in excel below. How can I summarize q2a - q2d in q3 as shown in excel below?
Hope to hear from you
sincerely Anders
q1 | q2a | q2b | q2c | q2d | q3 |
a | e | e | |||
a | b | b | |||
c | a | a | |||
b | d | d | |||
d | c | c |
Hi,
Is this what you are looking for? or i have not understand your requirement.
data have;
infile cards dsd dlm=',';
input q1 $ q2a $ q2b $ q2c $ q2d $;
q3=COALESCEC(q2a,q2b,q2c,q2d);
cards;
a,e,,,
a,b,,,
c,,,a,
b,,d,,
d,,,,c
;
run;
Thanks,
Shiva
Hi,
Is this what you are looking for? or i have not understand your requirement.
data have;
infile cards dsd dlm=',';
input q1 $ q2a $ q2b $ q2c $ q2d $;
q3=COALESCEC(q2a,q2b,q2c,q2d);
cards;
a,e,,,
a,b,,,
c,,,a,
b,,d,,
d,,,,c
;
run;
Thanks,
Shiva
Hi Shiva
Super. The COALESCEC(q2a,q2b,q2c,q2d) did the trick
I just did (data 'have' contains the values of q1 and q2a - q2d):
data want; set have;
q3=COALESCEC(q2a,q2b,q2c,q2d);
run;
Thank you for helping out.
cheers Anders
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.