Hello
I'm sure this is something simple but how do you create a grouping variable (say "Group") where Group=1 for for the first 10 observations, Group=2 for the next 10 and so on without writing
then
then
etc.etc.
or a loop of some sort.
Regards
Chris
I'm sure this is something simple but how do you create a grouping variable (say "Group") where Group=1 for for the first 10 observations, Group=2 for the next 10 and so on without writing
Code:
gen Group=1 if _n<=10
Code:
replace Group=2 if Group==. &_n<=20
Code:
replace Group=3 if Group=. & _n<=30
or a loop of some sort.
Regards
Chris

Comment