I hate to annoy you guys with this question, but I am getting the error "{ required" even though all my loops appear to be open (and closed) properly and unfortunately Stata doesn't tell you where the error is, so I can't figure out why this is happening. By the way if I take out the append_replace section with the if statements, I am still getting the same error, so I don't think it is from that section. Here is my code:
local vars = "any_rate resp_rate circ_rate weight_rate diabetes_rate gallstones_rate mental_rate cancer_rate std_rate died_rate"
local dates = "1947 1974"
foreach var of local `vars' {
foreach i of local `dates' {
forvalues j = 500(100)2500 {
local append_replace = "append"
if "`var'"=="any_rate" {
if "`i'" == "1947" {
if `j' == 500 {
local append_replace = "replace"
}
}
}
reg `var' post`i' dobdistfrom`i'change dobdistfrom`i'changesq post`i'_dist`i' post`i'_dist`i'sq if dobdistfrom`i'change < `j' & dobdistfrom`i'change > -`j', cluster(dobdistfrom`i'change)
outreg2 using Prelim_RD_Estimates.xls, `append_replace' excel dec(3)
}
}
}
Thanks so much for your help!