Hi, Not sure but will this work. data a; infile datalines delimiter='|'; input a : $10. b : $10. c : $10.; datalines; 10549|6453|5582 10549|6453|5217 10549|6453|2871 10549|2001|5582 10549|2001|5217 10549|2001|2871 10548|9648|6453 10548|9648|3251 10548|9648|2205 10548|9453|6453 10548|9453|3251 10548|9453|2205 ; run; proc sort data=a; by descending a descending b descending c; run; data b; set a; by descending a descending b descending c; retain _b _c; format _b _c $100.; if first.a then do; _b=b; _c=c; flag=1; end; else do; if findw(_b,b,',','T')=0 then do; if findw(_c,c,',','T') = 0 then do; flag=1; _c=cats(_c,',', c); _b=cats(_b,',', b); end; end; end; if flag=1 then output; drop _b _c; run;
... View more