- data a;
- input a b;
- cards;
- 1 2
- 1 3
- 1 4
- 2 3
- 2 5
- 2 6
- ;
- run;
- proc sort data=a;by a;run;
- data b;
- set a;
- by a;
- retain new_b;
- if first.a then do;
- new_b=compress(b);
- if last.a then output;
- end;
- else do;
- new_b=compress(new_b)||compress(b);
- if last.a then output;
- end;
- drop b;
- rename new_b=b;
- run;