Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Terminating a loop when a certain value is reached.


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Terminating a loop when a certain value is reached.
Date   Mon, 1 Apr 2013 13:30:03 +0100

Not much detail here.

One possibility is that you are forgetting that

if generationnum == 2

can only mean

if generationnum[1] == 2

Nick

On 1 Apr 2013, at 13:03, Stephen Cranney <scranney@sas.upenn.edu> wrote:

Hi all, I'm trying to figure out how to break out of a loop once a
variable is changed to a certain value. In each iteration, the value
is modified according to the inputs within the loop. I've tried to use
an "if" command:

if generationnum==2 {
       continue, break
       }

but it's still not terminating the loop. Does anybody know of a
command to terminate a loop once a specified calculated number is
reached?

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index