|
Re: 求助,数据合并
data a;
input x : $20. y;
cards;
aaa 1
bbb 2
aaa,bbb,ccc 3
aaa,bbb,ccc,fff 3
ddd 4
ddd,eee 5
fff 6
;
run;
proc sql;
create table exclu as select b.*
from a as a
inner join a as b
on index(trim(a.x),trim(b.x))and length(b.x)<length(a.x) ;
create table vicky as select distinct a.x,sum(b.y) as y_sum
from a as a
left join a as b
on index(trim(a.x),trim(b.x))>0
group by a.x;
create table vicky as select *
from vicky
where x not in (select x from exclu);
quit;
proc print data=vicky;
run; |
|