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.
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!
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.