C列和B列没有关系,C列只和A列有关系
data x;
input A B ;
cards;
2008 0
2008 1
2008 2
2008 3
2007 4
2007 5
2007 6
2007 7
2006 8
2006 10
2006 11
2006 12
2005 13
2005 14
;run;
proc sort data=x out=x1 nodupkey;by a;run;
proc sort data=x1;by b;run;
data x1;set x1;id=_n_-1;drop b;run;
proc sql;create table x2 as select x.*, x1.id
from x,x1 where x.a=x1.a order by id,b;quit;
data final;set x2;by id;
retain c 0;c+1;if first.id then c=id;run;
proc sql;drop table x ,x1, x2;run;