Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: foreach global macro not working with multiple macros


From   Nick Mosely <[email protected]>
To   [email protected]
Subject   st: foreach global macro not working with multiple macros
Date   Wed, 2 Feb 2011 09:00:13 -0800

Dear Stata world,

I would like to create a for loop using global macros but Stata
continues to return an error message. What's going on here?:

This code works fine:

global cash "pocket"
foreach y of global cash {
display "`y'"
}
>pocket

The following, code on the other hand, does not:

global cash "pocket"
global check "bank"
foreach y of global cash check {
display "`y'"
}
>{ required
>r(100);

I also tried:

foreach y of global $cash $check {
display "`y'"
}
>{ required
>r(100);

What gives?
~Nick Mosely
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index