I came across Mingfeng Lin's question:
> >> 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.
--
Alan Riley's answer covered what is possible from the review window by
filtering out the !_rc statements. However, there appears to be no
programmatic method to do so. I have written programs to strip
successfully completed command lines from general log files, but such
methods will not work with the new -cmdlog- feature. As part of my
-profile.do- I run a command log* appending each session's commands to
a serial log so that I don't inadvertently lose interactive commands
(especially useful for graph commands which are often incrementally
built)
Like Mingfeng I wish I could either (1) log only successful commands
or (2) have the _rc included in a preceding or following comment like:
balderdash
/*unrecognized command: balderdash
r(199);*/
or
/*r(199)*/ balderdash
This would make it relatively simple to find,examine and eliminate
manually or programmatically those error-producing statements even
long after the fact. I think the concept would be a useful -cmdlog-
option.
David Elliott
* Automatic Command Log creating code if anyone is interested:
==============================================
// Create a time-stamped default command log for every session
capture log using "`c(sysdir_personal)'command.txt", append text
noisily di _n(3) _dup(80) "*" _n ///
c(current_time) + " " + c(current_date) _n ///
_dup(80) "*" _n(2)
capture log close
cmdlog using "`c(sysdir_personal)'command.txt", append
==============================================
*
* 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/