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!