Star
Star

Reputation: 2299

How to force stopping execution in Stata

Is there a way to stop the execution of a do-file in Stata when an error occurs? The issue is that the do-file contains commands that could work despite the error.

Upvotes: 0

Views: 6304

Answers (1)

Nick Cox
Nick Cox

Reputation: 37278

Stata's view is that any error will result in an error message and force a command to finish; and so any program or do-file containing that command to finish; and so on. The definition of error here, perhaps unhelpfully but without circularity, is whatever produces an error message. An error could be, for example, a syntax error; reference to a command or program that is not visible; reference to a variable that is not visible.

Thus so far as I can see this question can only refer to something you regard as an error, but Stata does not.

It follows that you need to code so that what you regard as an error is identified and trapped with an error message.

I suggest that you give specific examples to get further advice, as your post is highly general and contains no code examples whatsoever. Note that Stata's capacity to do what you say rather than what you mean can not be regarded as an error except on the part of the programmer.

Upvotes: 1

Related Questions