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

Re: *** SPAM ALERT *** Re: st: -foreach- syntax


From   Jean-Benoit Hardouin <[email protected]>
To   [email protected]
Subject   Re: *** SPAM ALERT *** Re: st: -foreach- syntax
Date   Thu, 27 Oct 2005 22:59:43 +0200

My proposal is not the reason of your error !! The Nick's response certainly is the correct response ! Sorry
Jean-Benoit Hardouin

Jean-Benoit Hardouin a �crit :


I think that the correct syntax is

foreach x in q1y1989 q2y1989 q3y1989 q4y1989 q1y1990 q2y1990
q3y1990 q4y1990 q1y1991 q2y1991 q3y1991 q4y1991 q1y1992
q2y1992 q3y1992 q4y1992 q1y1993 q2y1993 q3y1993 q4y1993
q1y1994 q2y1994 q3y1994 q4y1994 q1y1995 q2y1995 q3y1995
q4y1995 q1y1996 q2y1996 q3y1996 q4y1996 q1y1997 q2y1997
q3y1997 q4y1997 q1y1998 q2y1998 q3y1999 q4y1999 q1y2000
q2y2001 q3y2001 q4y2001 q1y2002 q2y2002 q3y2002 q4y2002
q1y2003 q2y2003 q3y2003 q4y2003 q1y2004 q2y2004 q3y2004
q4y2004 q1y2005 q2y2005 {
    gen ratio`x'=lc`x'/dol`x'
}

Jean-Benoit Hardouin



Terra Curtis a �crit :

Dear Statalisters,
I am trying to run a foreach loop but I keep getting an error which is
puzzling me. My code is below, with the error:

Code:
foreach x in "q1y1989" "q2y1989" "q3y1989" "q4y1989" "q1y1990" "q2y1990"
"q3y1990" "q4y1990" "q1y1991" "q2y1991" "q3y1991" "q4y1991" "q1y1992"
"q2y1992" "q3y1992" "q4y1992" "q1y1993" "q2y1993" "q3y1993" "q4y1993"
"q1y1994" "q2y1994" "q3y1994" "q4y1994" "q1y1995" "q2y1995" "q3y1995"
"q4y1995" "q1y1996" "q2y1996" "q3y1996" "q4y1996" "q1y1997" "q2y1997"
"q3y1997" "q4y1997" "q1y1998" "q2y1998" "q3y1999" "q4y1999" "q1y2000"
"q2y2001" "q3y2001" "q4y2001" "q1y2002" "q2y2002" "q3y2002" "q4y2002"
"q1y2003" "q2y2003" "q3y2003" "q4y2003" "q1y2004" q2y2004" "q3y2004"
"q4y2004" "q1y2005" "q2y2005" {
gen ratio`x'=lc`x'/dol`x'
}

Error:
{ required
r(100);

end of do-file
r(100);

In my do-file the "foreach x in ..." line is all one line. And as you can
see I have included the "{". Can anyone spot the error?

Thanks,
Terra

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


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