Hi there,
I am running a nested loop using forvalues. the variables in the dataset are like this: admit_`i'_`j'
admit_1991_1 admit_1991_2 admit_1991_3
admit_1992_1 admit_1992_2 admit_1992_3 admit_1992_4 admit_1992_5
admit_1993_1 admit_1993_2 admit_1993_3 admit_1993_4
So bascially the j within each i is different. I have another set variables max_`i' (e.g. max_1991, max_1992 etc.) that indicate the maximum of j within each i.
Here is what I have and I got an invalid syntax message:
forvalues i=1991/1995{
local m=max_`i'
forvalues j=1/`m' {
replace flag=1 if admit_`i'_`j"==index_admit
}
}
Can anyone please help me out?
Thank you in advance.
Regards,
Hanzhang
I am running a nested loop using forvalues. the variables in the dataset are like this: admit_`i'_`j'
admit_1991_1 admit_1991_2 admit_1991_3
admit_1992_1 admit_1992_2 admit_1992_3 admit_1992_4 admit_1992_5
admit_1993_1 admit_1993_2 admit_1993_3 admit_1993_4
So bascially the j within each i is different. I have another set variables max_`i' (e.g. max_1991, max_1992 etc.) that indicate the maximum of j within each i.
Here is what I have and I got an invalid syntax message:
forvalues i=1991/1995{
local m=max_`i'
forvalues j=1/`m' {
replace flag=1 if admit_`i'_`j"==index_admit
}
}
Can anyone please help me out?
Thank you in advance.
Regards,
Hanzhang
Comment