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

st: RE: -foreach- syntax


From   "Steichen, Thomas J." <[email protected]>
To   <[email protected]>
Subject   st: RE: -foreach- syntax
Date   Thu, 27 Oct 2005 16:58:03 -0400

It's the missing quote mark at q2y2004.

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

-----------------------------------------
CONFIDENTIALITY NOTE: This e-mail message, including any attachment(s),
contains information that may be confidential, protected by the
attorney-client or other legal privileges, and/or proprietary non-
public information. If you are not an intended recipient of this
message or an authorized assistant to an intended recipient, please
notify the sender by replying to this message and then delete it from
your system. Use, dissemination, distribution, or reproduction of this
message and/or any of its attachments (if any) by unintended recipients
is not authorized and may be unlawful.


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