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

st: RE: foreach and globals and {.}


From   "David Harrison" <david.harrison@icnarc.org>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: foreach and globals and {.}
Date   Mon, 11 Apr 2005 11:11:47 +0100

foreach x of global out_`year' {
}

David


-----Original Message-----
From: Hans J. Baumgartner [mailto:hbaumgartner@diw.de]
Sent: 11 April 2005 10:56
To: statalist@hsphsun2.harvard.edu
Subject: st: foreach and globals and {.}


Dear statalist,

has anybody an idea how to solve the following problem?


foreach x in ${out_`year’} {
	do something
}

That is: I have several globals and I need the braces to tell Stata that
the local `year’ actually belongs to the global name.

Now I would like to run a loop over all elements in the global
${out_`year’}.

But the foreach command gets puzzled with the braces around the global,
since it thinks that this means to start the loop. And this returns an
error that a code follows on the same line as open braces.

How can I separate these braces?

Thanks
Hans

-- 
Hans J. Baumgartner DIW Berlin
German Institute for Economic Research
Dept. Public Economics
Königin-Luise-Str. 5; 14195 Berlin; Germany
Tel.: +49/30/89789-307
Fax.: +49/30/89789-114
http://www.diw.de
http://www.hansbaumgartner.de


*
*   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/




*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index