[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: re: WHILE command

From   Jeph Herrin <>
Subject   Re: st: re: WHILE command
Date   Tue, 18 Mar 2008 11:24:15 -0400

Agree that -while- is dispensible, but there are situations
(such as the one described here by Kit) where it makes for
much more readable code. Looking at

 while `grad'>=`eps' {

one knows right away what the loop is about. So let's not get
rid of it just yet.


Kit Baum wrote:
Nick W said

How does one do this in cases where one cannot calculate, in advance,
the number of repetitions needed, or the list of items to be acted upon?

As Nick C has pointed out, nothing stops you from using a forvalues loop over a large number of values and testing within the loop to determine whether some condition is now satisfied (e.g., if the norm of the gradient is now less than epsilon), and using

continue, break

to terminate the loop at that point.

Kit Baum, Boston College Economics and DIW Berlin
An Introduction to Modern Econometrics Using Stata:

* For searches and help try:

*   For searches and help try:

© Copyright 1996–2019 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index