Hi all,
I have a longitudinal data where each subject has a number of repeated measurements, i.e., occupying several rows in the data table. Unfortunately, the ID is not starting from 1. Now I would like to create a new ID, starting from 1. I have completed a SAS code as follows:
data original;
input ID ;
cards;
12
12
12
16
16
19
19
19
27
27
27
;
run;
data newID;
set original;
retain newID 1 previousID 12;
if ID=previousID then newID=newID;
else newID=newID+1;
previousID=ID;
drop previousID;
run;
Proc print data=newID noobs;
run;
This code works as I want. However, I feel the code complicated. Do you have any suggestion to make it simpler?
Thank you for reading!