From Stata to R: forvalues equivalent

Viewed 32

I am trying to replicate the following code from Stata to R and I am wondering what are the equivalent functions I need to use in order to create the forvalues loop in R.

egen MuncodeNum=group(muncode)

forvalues MI=1(1)2457{
    gen Muncode`MI'=(MuncodeNum==`MI')
    gen yearxMuncode`MI'=year*Muncode`MI'
}

Thanks so much in advance :)

0 Answers
Related