execution - Is there a way to tell Stata to execute the whole do-file ignoring the lines producing exceptions (or even syntax errors)? -


i run time-consuming code in background , oftentimes 10% of code not executed due small syntax mistake in beginning of do-file.

i prefer rest of do-file executed since mistake in beginning has no effect on computations @ end.

(version 2)

wanting stata ignore mistakes can mistaken.

  1. if there mistake in do-file, has implications follows.

  2. suppose got stata work wish. how know whether stata ignored important or trivial? if ignored trivial, should easy fix. if ignored important, wrong decision.

let's more constructive. do tells there nostop option. need careful how use it, can here.

the context of do, nostop precisely of op. people had do-files, expected take long time because of big datasets or lots of heavy computation, , set them going, historically "overnight" or "while went lunch". irritated find do-file had terminated on first error, , irritated if error trivial. so, idea of do, nostop do as can, aid debugging. example, suppose got variable name wrong in various places; generate y refer y later, doesn't exist. might expect find corresponding error messages scattered through file, can fix. error messages key here.

the point files once right, can save lots of time, no-one ever promised getting do-file right in first place easy.

my firm advice is: fix bugs; don't try ignore them.

p.s. capture mentioned in answer. capture may seem similar in spirit, used in similar style can bad idea.

capture eats error messages, user doesn't see them. debugging, opposite of needed.

capture programmer's command, , uses programmer being smart on behalf of user , keeping quiet it.

suppose, example, variable supplied numeric or string. if it's numeric, need a; if it's string need b. (either or b "nothing".) there branches this.

  capture confirm str variable myvar    if _rc { /// it's numeric         <do a>    }    else {         <do b>    }  

otherwise put, capture handling predictable problems if , arise. not ignoring bugs.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -