DATA D0; INPUT GroupNo; DATALINES; 1 1 1 2 2 3 3 3 ; /* You can skip sorting if data is already sorted */ proc sort data=d0; by GroupNo; run; /* You can put any other formated variable than A but keep in mind that a formated value should not be equal to actual value of the variable in any of the observation */ proc sql; create table d0_fin(DROP=A) as select PUT(GroupNo,Z5.) AS A, GroupNo, (monotonic() - min(monotonic())+1) as Rank from d0 group by a order by a, monotonic(); quit;
... View more