Hi all,'ve got the next dataset (have):
data have;
length subjid 8 color1 color2 $20;
input subjid $ color1 $ color2;
datalines;
1 blue blue
2 red grey
3 yellow blue
4 green green
5 black yellow
6 white pink
7 purple yellow
;
run;
I am interested to create a final dataset (want) like this:
color2 other
blue blue
grey
green green
yellow yellow
pink
as you can see I am interested to know which color in (color2) has been assigned to (color1), and which color in (color2) cant be assigned to (color 1) because are different (blanck values)...in this example would be grey and pink.
Thanks in advance,
V.
How about this:
data have;
input (subjid color1 color2) (:$);
datalines;
1 blue blue
2 red grey
3 yellow blue
4 green green
5 black yellow
6 white pink
7 purple yellow
;
proc sql;
select distinct a.color2, b.color1 as other
from have a
left join
have b
on a.color2=b.color1
;
quit;
Haikuo
maybe using arrays...please some help.
Thanks.
How about this:
data have;
input (subjid color1 color2) (:$);
datalines;
1 blue blue
2 red grey
3 yellow blue
4 green green
5 black yellow
6 white pink
7 purple yellow
;
proc sql;
select distinct a.color2, b.color1 as other
from have a
left join
have b
on a.color2=b.color1
;
quit;
Haikuo
Brilliant Hai.Kuo
Many thanks.
Cheers,
V.
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.