Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: Pgm 2 remove grammatical errors in log


From   Phil Schumm <[email protected]>
To   [email protected]
Subject   Re: st: RE: Pgm 2 remove grammatical errors in log
Date   Wed, 10 May 2006 17:42:33 -0500

On May 10, 2006, at 5:09 PM, Rodrigo A. Alfaro wrote:
I understand the program that Robert wants. But Martin's solution can be implemented in a do-file framework as the following example.

program clean
log using output, smcl replace
sysuse auto
valid reg price mpg
valid reg price mp3
log close
end

program valid
capture `0'
if !_rc `0'
end

The program clean has all your commands and put the results in a log file. I added Martin's program at the bottom of the file, in other words the do-file contains both programs (clean and valid). Then you have to type (the usual) -do clean- to load both programs and -clean- to run your routine.

I initially assumed (perhaps incorrectly) that the objective here was to take a log file resulting from an interactive session and purge it of commands that threw errors (and their corresponding output). Note that as long as the command that threw the error did not modify the data, this would be ok. But this may not always be the case, especially with poorly written commands. In that case, a log purged of these calls would be essentially useless (at least for replication, anyway). But Nick's correct -- if this is what you want to do, a scripting language with good text processing facilities would be the way to go.

That is not what's being demonstrated above, however. And I must say, I no longer understand the objective. If you're trying to debug something, you want to know where the errors (if any) occur. And with the proposed setup, you would essentially have to diff the file with the errors purged against the original program to see which line (s) caused errors (and were therefore struck). What exactly is the point here?


-- Phil

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* 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