I have the following problem with Stata 13.1: I am trying to run a loop with varying start and end points (determined by a numerical "year" variable), which will depend on fipscode. I would like to run the loop from the second-earliest year to the last year.
I run:
Stata returns r(198) syntax error. (The syntax error is not related to the contents of ** do something **.) The
command does work if I instead do:
My problem must come because
is not behaving as I think it is, but I don't know what my mistake is. If, for example, `min1' above is 1993, then when I do
I see 1994, as expected. To add to my confusion, though, if I do
I get 1998, while
returns 9966. Neither is the right answer and I don't know why the answers are different! Thank you in advance for correcting my misunderstanding.
I run:
Code:
quietly summarize year if fipscode == 17019 local min1 `r(min)' local max1 `r(max)' local startyear `min1'+1 forvalues y = `startyear'/`max1' { *** do something *** }
Code:
forvalues
Code:
forvalues y = `min1'/`max1' { *** do something *** }
Code:
local startyear `min1' + 1
Code:
di `startyear'
Code:
di `startyear'*5
Code:
di 5*`startyear'
Comment