You could use Marteen's very good idea to get something *close* to what
you want. Here is how I would do it:
- Read a .do or .ado file line by line using <file read>;
- Execute the line using <capture>;
- If there is no error, add that line to a macro followed by an
end-of-line character;
- If there is an error, continue to the next line;
- When you reach the end of your input file, copy the macro containing
the "good" lines to an output file using <file write>. Run the output
file to produce a clean log (assuming that none of the "good" lines
depends on the output of the "bad" lines).
Jean
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of
> Robert A Yaffee
> Sent: Wednesday, May 10, 2006 5:25 PM
> To: [email protected]
> Subject: Re: st: RE: Pgm 2 remove grammatical errors in log
>
> Martin,
> Your program seems to check for errors while your running
> the program.
> But it leaves all of the trace material in the log. I'm
> looking for a program that passes through the smcl file,
> finds the errors, makes a record of what line they are on,
> and then on a second pass erases the command generating the
> error and the error, to clean up the smcl file preparatory
> for a double check of the syntax.
> If you know of such a program, it would be helpful to get
> ahold of it.
> - Regards,
> Bob
>
> Robert A. Yaffee, Ph.D.
> Research Professor
> Shirley M. Ehrenkranz
> School of Social Work
> New York University
>
> home address:
> Apt 19-W
> 2100 Linwood Ave.
> Fort Lee, NJ
> 07024-3171
> Phone: 201-242-3824
> Fax: 201-242-3825
> [email protected]
>
> ----- Original Message -----
> From: Maarten Buis <[email protected]>
> Date: Wednesday, May 10, 2006 5:05 pm
> Subject: st: RE: Pgm 2 remove grammatical errors in log
>
> > ----Robert A Yaffee wrote:
> > > Does anyone know of a Stata do-file or ado-file program
> that will go
> > > through your log file, find the syntactical errors, and
> remove those
> > > errors along with the commands that generated them, leaving a
> > > syntactically perfect output?
> > > Once such garbage is removed, it's easier to check over the
> > output for
> > > other errors.
> >
> > Bob:
> > It is not exactly what you are looking for and if your
> programs take
> > long to run than this is not very efficient but something like this
> > may
> > help:
> > *-----------begin example------------
> > program valid
> > capture `0'
> > if !_rc `0'
> > end
> >
> > sysuse auto
> > set trace on
> > valid reg bla blub
> > valid reg price mpg foreign
> > *-----------end example-------------
> >
> > HTH,
> > Maarten
> >
> > -----------------------------------------
> > Maarten L. Buis
> > Department of Social Research Methodology Vrije
> Universiteit Amsterdam
> > Boelelaan 1081
> > 1081 HV Amsterdam
> > The Netherlands
> >
> > visiting adress:
> > Buitenveldertselaan 3 (Metropolitan), room Z214
> >
> > +31 20 5986715
> >
> > http://home.fsw.vu.nl/m.buis/
> > -----------------------------------------
> >
> >
> >
> > *
> > * 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/
> >
> *
> * 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/
>
*
* 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/