I can reproduce this.
It looks like a bug, as if Stata is looking
in (just) the wrong place.
Nick
[email protected]
Philip Greenwood
> I entered some code into Stata and the output was not as I
> expected. I've pasted the log below. Note there is no dataset
> loaded into memory.
> . do "oddcode"
>
> . foreach item in thing1 thing2 {
> 2. di "item: `item'"
> 3. local foo "a_great_big_fish"
> 4. foreach var of varlist _all {
> 5. di "variable: `var'"
> 6. }
> 7. }
> item: thing1
> variable: a_great_big_fish
> item: thing2
> variable: a_great_big_fish
>
> .
> end of do-file
>
> While it's questionable at best to enter the -foreach var of
> varlist _all- with no data loaded, I would not have expected
> the macro `var' to evaluate to the contents of `foo'. Can
> anyone tell me what is going on here?
*
* 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/