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

st: RE: Double -for- loop on one line crashes Stata (resend)


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Double -for- loop on one line crashes Stata (resend)
Date   Tue, 15 Oct 2002 17:31:47 +0100

Kaleb Michaud
> 
> Just an FYI - seems the more I use Stata, the more I'm 
> compressing my 
> code.  The following, independent of the actual command 
> used, crashes my 
> Stata every time (using Stata 7.0SE in Win2000 - causes 
> Stata to end, no 
> error message in results).
> 
> Feel free to tell me why so I don't assume such things will 
> work in the 
> future, but thought I'd share.
> 
> Kaleb...
> 
> 
> forvalues i =1/3 {forvalues j=1/3 {replace badcode = 
> badcode + "h`i'_`j'" 
> if hrec`i'_`j'chk>0 } }
> 
> I do know it works for one loop on one line, and this also 
> works fine in a 
> do file written as:
> 
> forvalues i =1/3 {
> 	forvalues j=1/3 {
> 		replace badcode = badcode + "h`i'_`j'" if 
> hrec`i'_`j'chk>0
> 	}
> }
> 

Apologies for previous premature send. 

I don't know if what appears in my mailer 
is exactly what you typed, but my advice 
is _never_ to place any text on a line after 
a left brace { in a loop. Always start a new 
line. 

Sometimes Stata can work out what you 
mean when you do that, but it is not 
guaranteed that it will be able to do so. 

This is perhaps tacit rather than explicit 
in documentation. 

Nick 
[email protected] 
*
*   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