Dear all,
I am a bit puzzled about the behavior of the group function. My dataset is like this (excluding the group column). I ran the following code and expected Stata to produce the column 'group' you see below. However, the result is a group column containing many different group numbers within the same year like 234, 23, 12, 1,...etc. Do you know by any chance the reason of this behavior?
Many thanks for your help!
Riccardo
I am a bit puzzled about the behavior of the group function. My dataset is like this (excluding the group column). I ran the following code and expected Stata to produce the column 'group' you see below. However, the result is a group column containing many different group numbers within the same year like 234, 23, 12, 1,...etc. Do you know by any chance the reason of this behavior?
Code:
bysort ID (year): gen group=group(year)
ID | year | var1 | group |
445678 | 2006 | 454 | 1 |
445678 | 2006 | 788 | 1 |
445678 | 2006 | 67567 | 1 |
445678 | 2006 | 546 | 1 |
445678 | 2007 | 678 | 2 |
445678 | 2007 | 7868 | 2 |
445678 | 2008 | 67878 | 3 |
445678 | 2009 | 6709 | 4 |
445678 | 2009 | 546 | 4 |
… | … | … | … |
Many thanks for your help!
Riccardo
Comment