Hi @djbateman
I think your idea is worth following. If I understood your input correct, so my test data is something similar to what you have, this would do it:
data have;
infile datalines truncover;
input ID $3. @5 List $char10.;
datalines;
001 A,B,C
001 A,B,C
001 A,B,C
002 A,C,D
002 C
002 A,C,D
003 A,B,C,D,E
004 A,B,C,D,E
004 A,B
004 C,D,F
;
run;
data t1;
set have;
do i = 1 to countw(List,',');
Item = scan(List,i,',');
output;
end;
run;
proc sql;
create table t2 as
select distinct ID, Item
from t1
group by ID;
quit;
data want (keep = ID List);
set t2;
by ID;
length list $12.;
retain List;
if first.ID then call missing (List);
List = catx(',', List, Item);
if last.ID then output;
run;
... View more