Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Is this peculiar, or is it me?


From   Philip Greenwood <[email protected]>
To   [email protected]
Subject   st: Is this peculiar, or is it me?
Date   Thu, 04 Nov 2004 17:51:40 +1100

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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index