Hallo Statalists.
I have the following question for you. Take the following two variables, id_code identifies the individual observations of a sample of individuals, N identifies the number of observations for each individuals. Observations are sorted by id_code:
id N
1 2
1 2
2 2
2 2
3 4
3 4
3 4
3 4
Hence N is obtained as: bysort id_code: gen N=_N
Unfortunately I do not observe id_code (although the data are sorted by it). I'd like to generate id, starting from:
N
2
2
2
2
4
4
4
4
Hope my question is clear. Any idea? Many thanks in advance!
Marianna
0 Response to How to identify ID_code from _N
Post a Comment