I'm trying to rollup rows of data into a single row with a variable that holds a value for each row that it rolled up. For example.
1 A
1 B
2 A
2 C
2 G
3 A
I need my end result to be
1 (A, B)
2 (A, C,G)
3 (A)
This is the code i'm using and I can get the single rows back but not the ID with multiple rows.
data z ;
set letter ;
length letters $20 ;
by id ;
letters='';
if first.id = 1 and last.id = 1 then do ;
letters=letter ;
output;
end ;
else if first.id = 0 and last.id = 0 then do ;
letters=letters || ' ' || letter ;
output ;
end ;
else if first.id = 0 and last.id = 1 then do ;
letters=letters || ' ' || letter ;
output ;
end ;
run ;
Thank you for any help.
... View more