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

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


From   Kaleb Michaud <[email protected]>
To   [email protected]
Subject   st: RE: RE: RE: Double -for- loop on one line crashes Stata
Date   Tue, 15 Oct 2002 13:34:47 -0500

At 06:28 PM 10/15/2002 +0100, you wrote:
Nick Winter
> > ... my advice is _never_ to place any text on a line after
> > a left brace { in a loop. Always start a new
> > line.
> >
>
> Still and all, presumably Stata
> should at
> least respond with an error message, rather than exiting completely.
> (Behavio(u)r I just confirmed.)

Agreed.

> I'll note also that  -if <condition> { do something }- works and is
> commonly used in both user and Stata-written code...

Indeed, including my own programs, until recently.
But my strong impression, fuelled by comments from
Stata developers, is that Stata has to
work very hard to let you do that in your code.
This is what I was curious about. All of the discussion on syntax/style is fine - I think you'd find my code to be written as you prefer - it was just a strange occurrence as I often will enter these loops in the command line manually and I never thought it was a problem.
Why should something like:

if `n' > 0 {di "This"...}

not be safe/smart in one line? Just curious if I should change the way I code.

Thanks,
Kaleb...

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