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
Count number of cases if dates are within a certain range (a la statsby)Greetings all, I have single line per observation survival data (4 million lines). Here is a simpli…
Generate balance tableHi, I'm trying to replicate this balance table (as in the picture) using some of the example dataset…
extract variable labels for new variable namesHi there I try to automate my programming as much as possible and one challenge I've come up agains…
Multinomial logit with sample selectionDear everyone, I am looking for something similar to Heckman selection model/svysemlog with a modi…
Manually installing Blindschemes by Daniel BischofDear Statalisters I admit this is a bit of a non-problem, but I'd like to find a solution nonethele…
Subscribe to:
Post Comments (Atom)
0 Response to Need Help on STATA loop
Post a Comment