Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Saving logfile in XML-format?

From   Neil Shephard <>
Subject   Re: st: Saving logfile in XML-format?
Date   Wed, 24 Feb 2010 09:57:00 +0000

On 02/23/10 15:06, wrote:
> Dear list,
> I just forgot the subject, so heres the same mail a second time...
> I´m pretty new to Stata and I´ve got a presumably simple-to-solve problem, even
> though I couldn´t find an answer in the web:
> Is there a possibility to save a logfile in xml-format?
> I´m about to calculate confidence intervals for the 95th centile for hundreds of
> datasets. I´m saving all the results in one logfile, and obviously I don´t want
> to type the results into Excel manually...
> Does anyone know how to do that?

One option is to use the -log2html- command to convert your log-file
to HTML, and then use a conversion tool to convert html to xml such as

A solution within Stata would be to use the returned scalars from each
calculation to write the confidence intervals to a text-file which you
then read into Stata and output using something like -xml_tab- or

A brief example follows...

*** Define a temporary file for writing results to */
tempfile t
*** Open the file and write a header line
file open results using `t', write replace
file write results "var,ci_95" _n
*** Load some sample data
sysuse auto, clear
*** Loop over three variables
foreach x of varlist mpg weight length{
***  Calculate the 95th centile
  centile `x', centile(95)
*** (Unnecessar, but return the results of the command so you can see
what scalar you need)
  return list
*** Write the results to the file, the current variable you are
summarising first, then the 95th centile
  file write results "`x',`r(c_1)'" _n
*** Close the results file
file close results
*** Read in the results
insheet using `t', clear
*** List them

The same can also be achieved using -postfile- to write results to,
and is probably a preferable approach (I used the above as I knew how
to do it off the top of my head, and always have to look up how to use
-postfile-, something I should remedy at some point!).

"... no scientific worker has a fixed level of significance at which
from year to year, and in all circumstances, he rejects hypotheses; he
rather gives his mind to each particular case in the light of his
evidence and his ideas." - Sir Ronald A. Fisher (1956)

Email -
Website -
Photos -

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index