Nick Winter
>
> I've whipped up the code below to turn a log file into a do
> file. The
> syntax is:
>
> . logtodo <logfilename> , saving(<dofilename>) [ replace ]
>
> It does not deal with a smcl-formatted log; use -translate-
> first. One
> annoying feature
> is that if the syntax that created the log file includes
> lines that are
> broken over multiple lines using /* and */, these are
> strung together
> into one long syntax line in the new do file. But the
> resulting syntax
> runs; it just doesn't look all that pretty.
>
> I've only tested it a bit, but it seems to work.
>
> program define logtodo
< snip >
Using -file- is surely a better approach
than treating each line of a log
as a value of a string variable.
One pitfall of this approach, however,
as mentioned earlier, is that macros
within command lines will probably
be substituted by empty strings.
In some cases they may get substituted
by other inappropriate values.
That is, when -file- writes
a line it writes what has been handed
to it after macro substitution by
Stata's interpreter.
Thus it seems to me that only tools
outside Stata offer a completely
pitfall-free approach to this
problem, which is a pity. If I
am right then only some change
at executable level can solve this.
Nick
[email protected]
*
* 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/