data ads;
input id x $ & 5.;
cards;
1 a b
1 b c d
2 x y
2 z
2 z y d
;
run;
data outds;
length newvar $200.;
set ads;
by id notsorted;
retain newvar;
if first.id then newvar='';
newvar=strip(newvar)||' '||strip(x);
if last.id;
keep id newvar;
run;