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

st: Problem with foreach


From   [email protected]
To   [email protected]
Subject   st: Problem with foreach
Date   Thu, 29 Jul 2004 16:30:15 -0400



Dear stata users,

I have a problem.

I have a list of countries. I put them in a macro.
When I run the loop, it works fine if I only ask for
basic tasks such as describe or su.
But when I try to do a bit more complicated tasks,
nothing appeared. It proceeds only for the first country.
And the remaining is blank.

local country "Benin Togo France"
foreach i of local country {
 use `i'.dta
 di "I use `i'"
 d
}

here it works for each country ( I have all the description).

But when I code:
local country "Benin Togo France"
foreach i of local country {
 use `i'.dta
 di "I use `i'"
 g id = _n
 codebook id
}


It works only for the first country: Benin.

. I use Benin
 output omitted
. I use Togo
. I use France

What is happening?
Do I omit something?

Best regards.

Amadou.

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