Statalist


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

st: capture blocks


From   Philipp Rehm <[email protected]>
To   [email protected]
Subject   st: capture blocks
Date   Sun, 29 Jun 2008 12:22:38 +0200

.
My question is whether there is a way to force Stata to run trough a do-file without aborting when there is an error. I know that I can use -capture- for this. Example:

sysuse auto, clear
cap noisily rename rep76 whatever
cap noisily rename rep77 foo
cap noisily rename rep78 bar

I was hoping / expecting that -capture- with {} would let me do this on a whole block of commands. Example:

sysuse auto, clear
capture noisily {
rename rep76 whatever
rename rep77 foo
rename rep78 bar
}

However, this will abort after the first line (which contains an error). This behavior is documented in the manual: "If any of the commands in the capture block fail, the subsequent commands in the block are aborted" ([P], Release 9, p. 21)

So, is there a way to run a *block* of commands without having to put the -capture- in front of each command?

Stata 9, Win XP.

Thank you very much!
Philipp

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