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   "Sergiy Radyakin" <[email protected]>
To   [email protected]
Subject   Re: st: -log- in Stata to bypass commands that resulted in errors?
Date   Fri, 31 Oct 2008 17:15:40 -0400

On Thu, Oct 30, 2008 at 6:39 PM, Alan Riley <[email protected]> wrote:
> Mingfeng Lin ([email protected]) 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.
>

2Mingfeng Lin

  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.

Regards, Sergiy

>
> --Alan
> ([email protected])
>
> *
> *   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index