Hi
I believe the code below does what you're looking for:
data have;
infile datalines truncover;
input Name $ Color $ Age Enrolled $ ;
datalines;
Jo red 24 Y
Jo blue 24 Y
Ray red 31 Y
MIke blue 28 N
;
run;
proc sql;
select
name
,max(case(color) when ('blue') then color else '' end) as blue
,max(case(color) when ('red') then color else '' end) as red
,age
,enrolled
from have
group by name,age,enrolled
;
quit;
This example covers the cases 'red' and 'blue' - but what if one doesn't know for sure what colours will be in the data.
I thinks this is a case where an approach using PROC TRANSPOSE would allow a more dynamic solution.
HTH
Patrick
... View more