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 at the end of May, and its replacement, statalist.org is already up and running.


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

AW: st: Saving logfile in XML-format?


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   AW: st: Saving logfile in XML-format?
Date   Wed, 24 Feb 2010 11:04:27 +0100

<> 

" and always have to look up how to use
-postfile-, something I should remedy at some point!)."


My remedy is the following template which I store in my text editor and then
edit for the specific task at hand:


*************
/*
 -postfile- example 
*/

tempname hdle

capt erase info.dta

postfile `hdle' /*str10 */ suc se /* 
*/ using info

qui forv i=0/100{
		cii 100 `i', level(99)
		post `hdle' (`i') (r(se))
}

postclose `hdle'

u info, clear
l, noobs //sepby() sep(0)

*************


Credits to Philippe`s
http://www.stata-journal.com/article.html?article=pr0036 where I intially
obtained parts of this template.


HTH
Martin

-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Neil Shephard
Gesendet: Mittwoch, 24. Februar 2010 10:57
An: statalist@hsphsun2.harvard.edu
Betreff: Re: st: Saving logfile in XML-format?

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/


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