Hello, Everyone,
I want to assign individuals (id) into groups of five (group) in the following pattern -- how should I write stata code using "foreach" or maybe "forvalue"?
replace group=1 if id>=1 & id <=5
replace group=2 if id>=6 & id <=10
replace group=3 if id>=11 & id <=15
replace group=4 if id>=16 & id <=20
replace group=5 if id>=21& id <=25
.......
Thanks a lot!
Related Posts with Need Help on STATA loop
Adding gap years in the observationsHello everyone, I have three variables in my dataset - company name, year, and profit. The year var…
Multilevel mixed-effects negative binomial regressionI am running a multilevel mixed-effects negative binomial regression and have two questions I'd like…
Help with parsing values in variablesDear Statalist, I'll like to create var3 as a dummy variable, with the value of 1 where an ID in var…
How generate terrain ruggedness, elevation over sea level and distance to points of interest?Hi, I am new in Stata. I don't find codes to generate terrain ruggedness, elevation over sea level a…
Need help figuring out this commandHi! I need help with a question on my stats homework and I cannot figure out how to set up this comm…
Subscribe to:
Post Comments (Atom)
0 Response to Need Help on STATA loop
Post a Comment