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
Related Posts with How to identify ID_code from _N
Why do Poisson and Negative Binomial Regressions yield the same result?I am using the count data models as I have a count dependent variable (0, 1, 2, 3, 4). There is no …
how to use firm new names to replace old names in two different dataset? Code: * Example generated by -dataex-. To install: ssc install dataex clear input str65 firmNameNow…
Generalized difference in differenceI'm studying the causal effects of a state policy, nurse practitioner scope of practice law, on vari…
how to use firm new names to replace old names in two different dataset? Code: * Example generated by -dataex-. To install: ssc install dataex clear input str65 firmNameNo…
Merge data set WhartonHello, I have downloaded two datasets from Wharton. One CRSP/Compustat Merged - Fundamentals Annual…
Subscribe to:
Post Comments (Atom)
0 Response to How to identify ID_code from _N
Post a Comment