Can someone please explain to me why one cannot use scalars to define the
upper bound in a range of a forvalues loop. A forvalues loop with a local
works, a while loop with a scalar works, a while loop with a local works,
but not a forvalues loop with a scalar. There seems to be nothing in the
programming manual about this issue.
This is the code for the examples above:
tempname m1 m2
scalar `m1'=5
local `m2'=5
forvalues a=1(1)``m2'' {
di "`a'"
}
local a=1
while `a'<=``m2'' {
di "`a'"
local a=`a'+1
}
local a=1
while `a'<=`m1' {
di "`a'"
local a=`a'+1
}
forvalues a=1(1)`m1' {
di "`a'"
}
I am using Stata 8.2 SE with XP.
DVM
_______________________________________________________________________________
Dimitriy V. Masterov
Work:
Center for Social Program Evaluation
1155 East 60th St. Room 038
Chicago, IL 60637
Work: (773)256-6005
Fax: (773)256-6313
Home:
1312 East 53rd St., Apt.309
Chicago, IL 60615
Mobile: (773)220-2760
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/