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

st: RE: Table Command to Matrix or CSV


From   Roger Newson <roger.newson@kcl.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   st: RE: Table Command to Matrix or CSV
Date   Mon, 07 Feb 2005 11:40:28 +0000

Something like Tristan wants can be done using the -xcontract- package together with - -listtex-. For details on the use of these packages (downloadable from SSC), Tristan might like to refer to my presentation "From datasets to resultssets in Stata", given at the 10th UK Stata User Meeting in 2004 and downloadable from my website (see my signature below). Another reference, also downloadable as a preprint from my website, is Newson (2003). Both of these documents can be located and downloaded from within Stata using the -findit- command, as in

findit resultsset

or

findit enduser

I hope this helps.

Roger


References

Newson R. 2003. Confidence intervals and p-values for delivery to the end user. The Stata Journal 3(3): 245-269.


At 21:25 06/02/2005, Tristan wrote:

Is there a fast way to get the results of a twoway table with multiple
statistics into a matrix format so I can access all the results
programmaticly.  I'm hoping to create a way to produce a latex table
from the table command.  Suggestions?

I assume there is nothing like this already made (I'm aware of
labtabstat outtable etc).  Ideally it would produce a latex file with
rows and columns plus multiple lines within each cell for each
statistic.

Tristan

On Thu, 3 Feb 2005 16:50:28 -0500, Daniel Egan <dp.egan@gmail.com> wrote:
> > > Is there a way to get the results from a table command into a matrix
> > > or CSV file?  In the end I want in Excel.
> > >
> > > The command I'm running is:
> > > table x y, c(sum z mean z) row col
> > >
> > > I know there are things like this for reg, tabstat, sum etc but can't
> > > find anything for "table" and can't easily replicate the format using
> > > other commands.
>
> 1)a simple-yet-effective-(yet-inefficient) option is to use log2html.
> It will require copying and pasting, but the table will be correctly
> formated.
>
> copy and paste (from your browser) the table. It will (usually) paste
> as one column. Do Data>Text to Columns>fixed>finish.
>
> 2) use the -replace- option. This changes the data as -collapse- does,
> but is just an option on table. I assume you have a .do file, but
> basically:
>
> ---do file----
> *table 1
> use foo.dta, clear
> table table x y, c(sum z mean z) row col replace
> outsheet using table1, comma replace
>
> *table 2
> use foo.dta, clear
> table table a b, c(sum z mean z) row col replace
> outsheet using table2, comma replace
> --------enddo-------------
>
> Just a matter of taste and particulars...
>
> The table problem is somewhat interesting, as if I am doing this on
> the fly, in Windows when I right click, I have the option of "copy
> table", which correctly (via tabs?) delimits the table for pasting in
> excel. I have no idea how this works, but I wonder if there is some
> shell command to utilize it.
> I'm not touching that one however...
>
> cheers,
>
> Dan
> *
> *   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/
>
*
*   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/

--
Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
King's College London
5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom

Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
  or 020 7848 6605 International +44 20 7848 6605
Email: roger.newson@kcl.ac.uk
Website: http://phs.kcl.ac.uk/rogernewson/

Opinions expressed are those of the author, not the institution.

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index