Here's another option:
data temp ;
input ID $ val $ source 8.;
datalines;
V1 0 1
V1 10 1
V1 100 2
V1 250 2
V2 50 1
V2 80 1
V2 500 2
V7 10 1
V7 20 1
V7 30 2
V7 99 2
;
run;
proc sort data=temp;
by id source;
run;
Data temp2;
retain Arr_good Arr_Bad;
length arr_good $50. arr_bad $50.;
set temp;
by id source;
if first.source and source=1 then Arr_good=val;
else if source=1 then arr_good=cats(arr_good,',',val);
if first.source and source=2 then Arr_bad=val;
else if source=2 then Arr_bad=cats(arr_bad,',',val);
if last.id then output;
drop val source;
run;
... View more