Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: -log- in Stata to bypass commands that resulted in errors?


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: -log- in Stata to bypass commands that resulted in errors?
Date   Mon, 3 Nov 2008 11:26:18 -0000

Sergiy is correct in principle, and no doubt he could easily think up
examples in which you would get bitten. 

In practice almost all (well-written) commands kick you out long with an
error before they do anything and above all before they change 
the data or key settings. Also, if your own commands or do-files do
this, the blame is easy to identify. 

Nick 
n.j.cox@durham.ac.uk 

Sergiy Radyakin

  in general this does not guarantee however, that once you replay the
resulting list of commands you get the same results as you have when
you saved the list. The commands where errors occured in general could
do actions that changed the data or the settings of Stata that can
affect the further chain of events.

Alan Riley <ariley@stata.com> wrote:

> Mingfeng Lin (mingfeng.lin@gmail.com) asked about saving all
> commands which did not result in an error:

>> I'm just curious if there is a way (or maybe an add-on) in Stata to
>> create a log file for only the correct commands? -log using- or -#
>> review- will capture all commands that have been typed in the window,
>> including those resulting in errors.  If there is a way for the log
to
>> automatically filter out those commands, it would be really nice,
>> especially replicating what we do in an interative manner with Stata.
>
> It is possible to do this from Stata's Review window, which displays
> a history of commands submitted to Stata.  Follow the steps below
> to save a .do file consisting of all interactive commands which did
> not result in an error.
>
> There are three columns in the Review window: sequence number (the
> order in which commands were submitted to Stata), command (the command
> itself), and return code (empty if the command completed successfully;
> the return code, or '_rc' from the command if it exited with an
> error).
>
> After issuing several commands to Stata interactively, some of which
> might have resulted in errors, click on the top of the return code
> (_rc) column in the Review window.  This will sort the commands
> in the Review window such that all the commands which did not result
> in an error are grouped together (and within that group they will
> be in the order in which they were submitted to Stata).  Beneath them
> will be all the commands resulting in errors, sorted by the return
> code.
>
> The first group is of interest; the second can be ignored.  Select
> all commands in the first group: click once on the first command
> in the group to select it, scroll until the last command in the group
> is visible, and then hold down the shift key while clicking on it
> to select all commands from the first one through the last one in
> the group.
>
> Once all of the valid commands have been selected, right-click
anywhere
> in the Review window and choose "Save Selected..." to save those
commands
> to a .do file, or choose "Send to Do-file Editor" to paste those
commands
> into Stata's Do-file Editor.

Regards, Sergiy

>
> --Alan
> (ariley@stata.com)
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index