data a;
input a b c;
cards;
2 2 1
2 2 1
3 1 2
3 1 2
9 9 9
8 8 8
;
run;
proc sql;
create table f as
select a,b,c,count(*) as cishu from e
group by a,b,c
having(count(*))>1
;
data h (drop=cishu i);
set f;
do i=1 to cishu;
output;
end;
run;
data j;
retain n;
set h;
by a b c notsorted;
if first.c then n+1;
run;