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

From |
Alan Riley <ariley@stata.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: -log- in Stata to bypass commands that resulted in errors? |

Date |
Thu, 30 Oct 2008 17:39:11 -0500 |

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. --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/

**Follow-Ups**:**Re: st: -log- in Stata to bypass commands that resulted in errors?***From:*"Sergiy Radyakin" <serjradyakin@gmail.com>

**References**:**st: -log- in Stata to bypass commands that resulted in errors?***From:*"Mingfeng Lin" <mingfeng.lin@gmail.com>

- Prev by Date:
**st: Re: scalar for arima regression and generating new variables** - Next by Date:
**Re: st: St: Spectral Analysis** - Previous by thread:
**st: RE: -log- in Stata to bypass commands that resulted in errors?** - Next by thread:
**Re: st: -log- in Stata to bypass commands that resulted in errors?** - Index(es):

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