这个如何?
data test;
input a $ b $ c;
datalines;
s1 d3 0
s1 d1 2
s1 d2 3
s2 d3 0
s2 d1 1
s2 d4 2
s2 d5 7
s2 d6 8
s3 d3 1
s3 d1 1
s3 d2 2
s3 d4 0.5
s3 d5 0.5
s3 d7 8
s3 d9 12
;run;
proc sort data=test out=testgp;
by a c;
data testgp;
set testgp;
by a;
if first.a then group+1;
call symput("ngroup", group);
run;
%macro getmin2;
data new;
set testgp;
if group=1;
data min2;
set new(obs=2);
run;
%do i=2 %to &ngroup;
proc sql;
create table new as
select * from testgp where group=&i and b not in (select b from min2);
data min2;
set min2 new(obs=2);
run;
%end;
%mend;
%getmin2;
proc print data=min2;run;
5# lachance