| ![]() |
From | Jeph Herrin <junk@spandrel.net> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: RE: RE: Use of -exit- within -foreach- or -forvalues- |
Date | Mon, 30 Oct 2006 21:02:09 -0500 |
Try -exit 0- Ben Jann wrote:
Absolutely. However, there are cases in which a program (usually a
subroutine to some other program) should exit without returning error. Thanks, ben
Scott wrote:
If you add a return code, then the code will stop within the loop: prog foo3 local num 1 2 3 foreach n of local num { if "`n'"=="2" { di "`n' => exit" exit 119 } di "`n'" mac shift } di "not to be reached" end . discard . foo3 1 2 => exit r(119); prog foo4 local list 1 2 3 foreach l of local list { di "`l'" exit 119 } di "howdy" end . foo4 1 r(119);* * 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–2025 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |