反正
[code:13u1f1tm]data have;
input x @@; cards;
1 2 2 2 1 1 1 2 2 1 2
;
data have_1;
do until(Eof1);
set have end = Eof1;
n1 = sum(n1, x=1); n2 = sum(n2, x=2);
end;
do until(Eof2);
set have end = Eof2;
n_1+x=1; n_2+x=2;
x_new = x;
if (n_2 le 2 and x = 2) then x_new = 1; *first m = 2;
if (n1-n_1 lt 1 and x = 1) then x_new = 2; *last n = 1;
output;
end;
keep x x_new;
run;[/code:13u1f1tm]