Hi,
In my data I have a variable that has a variable ID with values such as: 220, 240, 470, 1120, 2840, 8710, etc. I want to generate a more simple identifying variable, say ID2, with numbers running from 1 to [number of distinct values in ID].
I know I can do this by hand using a number of replace commands, but as my data contains 60+ distinct values in ID, I'd prefer to do with using a loop. But unfortunately I am not very experienced with Stata so I could use some help with this.
In my data I have a variable that has a variable ID with values such as: 220, 240, 470, 1120, 2840, 8710, etc. I want to generate a more simple identifying variable, say ID2, with numbers running from 1 to [number of distinct values in ID].
I know I can do this by hand using a number of replace commands, but as my data contains 60+ distinct values in ID, I'd prefer to do with using a loop. But unfortunately I am not very experienced with Stata so I could use some help with this.
Comment