Basic approach:
proc sort data=have;
by id datecounter;
run;
data want;
set have;
retain rank;
by id;
if first.id then rank=1;
else rank+1;
run;
Note: this assumes that your dates are actually SAS date values and not some character version.
The sort may not be needed if your data is in order.
Retain keeps the values of a variable across data step boundaries.
When you use a By group then SAS creates automatic variables that indicate whether the current observation is the first or last of a by group and are 1/0 (true/false) valued so can be used in If as shown. Note the dot following the keyword First, or Last, then the variable name without a space.
Personally I would call this an ORDER - sequence determined, not a Rank -size of value involved.
... View more