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

st: RE: RE: inner loop


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: inner loop
Date   Tue, 5 Nov 2002 20:58:49 -0000

James Jetton
> 
> Nested for loops often fail if the ids are not explicitly 
> specified. 
> For example
> 
> for any a b c: for num 1984/2000:
> 
> will fail but
> 
> for X in any a b c: for Y in num 1984/2000:
> 
> will work.
> 
> This appears to be a bug in the for ado. Been bitten by this 
> hemipteran more than once.
> 
 
The bug here, I suggest, is in documentation 
which suggests (or implies) that nested -for-s 
will necessarily work. 

The on-line help for -for- is one example. 

The sad fact is that sometimes they will, 
and sometimes they won't, for reasons 
best explained by Alan Riley and Bobby Gutierrez 
in a Statalist posting on 15 October. 

The only general advice is to avoid nested 
-for- in favour of -forval- and/or -foreach-. 

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