Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Turning log files into do files

From   "Nick Cox" <>
To   <>
Subject   st: RE: Turning log files into do files
Date   Mon, 7 Oct 2002 16:31:05 +0100

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. 

*   For searches and help try:

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