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, statalist.org 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 <nshephard@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Saving logfile in XML-format?
Date   Wed, 24 Feb 2010 09:57:00 +0000

On 02/23/10 15:06, aschaich@smail.uni-koeln.de 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
http://sourceforge.net/projects/light-html2xml/


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
-dataout-

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
list

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!).

Neil
-- 
"... 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 - nshephard@gmail.com
Website - http://slack.ser.man.ac.uk/
Photos - http://www.flickr.com/photos/slackline/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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