Another approach,
data test; input adverse $ 1-12 count1; cards; Diarhoea [1] 170 Diarhoea 100 Rash [2] 174 Rash 145 Nausea [3] 123 Nausea 67 Anemia [4] 156 Cardiac 167 Fatigue 174 ; run; data want;
set test;
by adverse notsorted;
adverse1=scan(adverse,1,'[ ');
run;
data want2;
length adverse2 $200;
set want;
retain adverse2;
by adverse1 notsorted;
if first.adverse1 then adverse2=adverse;
run;
data want3(rename=(adverse2=adverse));
set want2;
by adverse2 notsorted;
if last.adverse2;
drop adverse1 adverse;
run;
... View more