Statalist


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

Re: st: WHILE command


From   "Eva Poen" <[email protected]>
To   [email protected]
Subject   Re: st: WHILE command
Date   Mon, 17 Mar 2008 07:18:05 +0000

Vincent,

I believe the answers are "yes" and "yes". See the example below.

local i 0
local j 10

while `i' < `j' {
	di ""
	di "before updating: i `i' , j `j' "
	di ""
	local ++j
	local i = `i' + 3
	di "after updating: i `i' , j `j' "
	di ""

}

di "end of loop: i `i' , j `j' "

Eva

2008/3/17, Vincent Davis <[email protected]>:
> I have a few questions about the WHILE command,
>  1. When does it evaluate the WHILE condition? If it becomes false does
>  it immediately exit the WHILE loop?
>  2. Can both sides of the WHILE condition be local variables that may
>  be updated in the WHILE statement ?  WHILE 'i' < 'j' {  ..... local i
>  = 'i' + 'j' .... local j = 'j' + 1.....  }
>
>
>  --
>  Thanks
>  Vincent Davis
>  *
>  *   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/
>
*
*   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