[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
Kit Baum <baum@bc.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: re: table command to matrix |

Date |
Sun, 6 Feb 2005 17:54:16 -0500 |

Tristan said

"

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

This does not produce the within-each-cell format, but the ability to do that just involves some LaTeX directives applied to the result. The 'replace' option on 'table' is the key to hanging on to its results:

sysuse auto

preserve

table rep78 foreign,c(sum price mean price median mpg max weight) replace

rename table1 sum_price

rename table2 mu_price

rename table3 median_mpg

rename table4 max_weight

mkmat *,mat(a)

mat rownames a= 1 2 3 4 5 6 7 8

outtable using cars,mat(a) replace

--------

% matrix: a file: cars.tex 6 Feb 2005 17:49:34

\begin{table}[htbp]

\begin{tabular}{|l|l|l|l|l|l|l|}\hline

& rep78 & foreign & sum price & mu price & median mpg & max weight \\ \hline

1 & 1 & 0 & 9129 & 4564.5 & 21 & 3470 \\ \hline

2 & 2 & 0 & 47741 & 5967.625 & 18 & 3900 \\ \hline

3 & 3 & 0 & 178391 & 6607.0742 & 19 & 4840 \\ \hline

4 & 3 & 1 & 14486 & 4828.6665 & 23 & 2130 \\ \hline

5 & 4 & 0 & 52934 & 5881.5557 & 18 & 4130 \\ \hline

6 & 4 & 1 & 56353 & 6261.4443 & 25 & 2750 \\ \hline

7 & 5 & 0 & 8409 & 4204.5 & 32 & 2120 \\ \hline

8 & 5 & 1 & 56634 & 6292.6665 & 25 & 3170 \\ \hline

\end{tabular}

\end{table}

Of course one could probably do that with tabstat, too.

Kit

Kit Baum, Boston College Economics

http://ideas.repec.org/e/pba1.html

*

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

- Prev by Date:
**st: RE: Prcounts** - Next by Date:
**st: re: speeding up mkmat** - Previous by thread:
**RE: st: RE: Prcounts** - Next by thread:
**st: re: speeding up mkmat** - Index(es):

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