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.
Missed SAS Innovate in Orlando?
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.