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: Save the Date
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!