伊ò太ジ刀 发表于 2015-1-10 20:21 
要怎么写?
既然你问了,我就尝试写一下吧
data a;
input g1 $ g2 $ x;
cards;
A B 1
B C 2
C D 3
E F 4
G F 5
;
run;
proc sort; by g1 g2; run;
data b;
set a;
retain str n; length str $200;
array glst g1 g2;
if count(str, g1, 't') = 0 and count(str, g2, 't') = 0 then do;
n + 1;
str = compbl(g1||g2||str);
id = compress('0'||n);
group = g1;output;
group = g2;output;
end;
else do;
do over glst;
if count(str, glst, 't') = 0 then do;
str = compbl(glst||str);
id = compress('0'||n);
group = glst;output;
end;
end;
end;
keep group id;
run;