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

st: RE: convert a log file into a do file


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: convert a log file into a do file
Date   Mon, 7 Oct 2002 11:26:54 +0100

Zhiqiang Wang
> 
> I would like to convert a long .log file into a .do file. I 
> remember the
> similar question was asked on Statalist years ago but just 
> cannot find it.
> Any suggestions would be appreciated very much.

I guess from this that the key task is to 
extract the command lines from 
among the results. 

One set of suggestions for doing this kind of thing
was written up in STB-19 in 1994
in an insert "Using awk and fgrep for selective 
extraction from log files". 

The principle is simply to identify command 
lines as lines starting with ". " or "> .".
You can also combine initial command lines with 
continuation lines with some script in Awk, 
Perl, Python, etc. or a decent text editor's 
macro or other language. I found an Awk 
script in my files. I may have the Perl 
equivalent somewhere. 

It is natural to wonder whether Stata 
itself could be used to do this. 
That is, can you read in a log file as
a string variable and process it in 
some way? My guess is 
that a limit on this is whether you employ 
local or global macros. If you 
do, then they are likely to get blanked 
out as Stata will interpolate the 
current value, often empty. If 
you don't, then this could be the 
easiest way to do it. However, 
very long command lines could 
easily overflow even the -str244- 
limit of Stata/SE.  

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/



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