Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Bornschein <nick.bornschein@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: loop with global marco |
Date | Wed, 19 Feb 2014 13:42:50 +0100 |
When I use su $var1 or any other global, it works perfectly, but not within the loop. Am 19.02.14 13:33, schrieb Nick Cox:
foreach x in $var1 $var2 $var3 That way the macroname gets expanded to the macro contents and -foreach- just sees the results of that, not the globals. Nick njcoxstata@gmail.com On 19 February 2014 12:23, Nick Bornschein <nick.bornschein@gmail.com> wrote:Hello, I defined 3 global macros, each of them containing the names of variables: (... means there are a lot more variables in it) global var1 "hope truth..." global var2 "life death..." global var3 "never loose..." Now I want to summarize the global macros in blocks with: foreach x of global var1 var2 var3 { su `x' } But it does not work, it always runs through all variables without creating blocks. What is the problem? -Nick * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/* * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/
* * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/