data have;
input ClassID;
datalines;
1
1
1
2
2
2
3
3
3
3
;
run;
data want;
set have;
by ClassID;
retain ID;
if first.ClassID then ID = 1;
else ID = ID + 1;
output;
run;
Note: I am assuming your input data is sorted by ClassID.
SAS Innovate 2025: Register Now
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9. Sign up by Dec. 31 to get the 2024 rate of just $495. Register now!