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

st: Re: Re: Question: Saving table result


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   st: Re: Re: Question: Saving table result
Date   Wed, 18 Feb 2004 11:11:35 -0500

I have written an ado that makes this process easier.  It writes a matrix to
a tab delimited text file.  Instead of using svmat or svmat2 and dropping
vars and outsheet and then needing to relaod your data as in the example,
you could just:

tabstat .....save
tabstatmat matvars
mat2txt , matrix(matvars) saving(mytable1.txt)

the ado also gives options for a table title and a table note (at the
bottom) and allows you to replace existing files or append onto them as well
as set the numeric formatting for columns.  I can send it to interested
parties and/or post it to SSC if there is interest.  It uses the file
command so it doesn't disturb your current data and works quickly (no
preserve,restore).

Michael Blasnik
[email protected]

----- Original Message ----- 
From: "Friedrich Huebler" <[email protected]>
To: <[email protected]>
Sent: Tuesday, February 17, 2004 6:26 PM
Subject: st: Re: Question: Saving table result


> --- [email protected] wrote:
> > Dear Statalist,
> >
> > I have a simple question.
> > I conducted "tabstat"(see below)command for my data.
> > How can I save the result table as a data file?
> > I have to import the result table into EXCEL.
> > Please help me out.
> > Thanks.
> > sugie
> >
> > -----------------------------------------------------
> > .tabstat pop7 pop8 pop9 pop0, by(city) stats(sum) save
> >
> > Summary statistics: sum
> >   by categories of: city
> >
> > city  |      pop7      pop8      pop9      pop0
> > ------+----------------------------------------
> > city_A|      8695      8739      7132      9488
> > city_B|    956612    760833    683461    642044
> > city_C|    751015    695510    655468    644137
> > city_D|    346775    433034    484904    567810
> > ------+----------------------------------------
> > Total |   2063097   1898116   1830965   1863479
> > -----------------------------------------------
>
> Sugie,
>
> If you don't need the first -tabstat- column you can save the
> generated values with the help of the -tabstatmat- and -dropmiss-
> packages from SSC.
>
> . ssc install tabstatmat
> . ssc install dropmiss
>
> Example using the auto data:
>
> . sysuse auto, clear
> . tabstat price weight, by(foreign) stats(sum) save
> . tabstatmat matvars
> . svmat matvars
> . keep matvars*
> . dropmiss, obs
> . outsheet using table.txt
>
> The tab-delimited file table.txt can be opened in Excel.
>
> Question to other list members: How can the first -tabstat- column be
> saved together with the other columns?
>
> Friedrich Huebler


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