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

Re: st: storing tables and values in tables

From   "Austin Nichols" <>
Subject   Re: st: storing tables and values in tables
Date   Thu, 28 Feb 2008 01:37:52 -0500

Adrian de la Garza <>:
One solution is to make the tab using an estimation command.  The
coefs and SEs are available after estimation commands as matrices and
as scalars (see [U] 13.5 for the latter, and also try -eret list-
after any estimation command for the former).  Here's a variety of

sysuse nlsw88, clear
tab collgrad ind, row nofr
proportion ind, over(coll)
mat li e(b)
test [Mining]_b[_subpop_1]=[Mining]_b[_subpop_2]
g one=1
svyset [pw=one]
svy: tab collgrad ind, row se
di _b[p24]
di _se[p24]
test _b[p22]=_b[p12]
mat b=e(b)
mat b24=b[1,"p24"]
mat li b24
mat V=e(V)
mat V24=V["p24","p24"]
mat li V24
di sqrt(V24[1,1])

[The se option on svy: tab is not optional; if you leave it off, the
e() results will contain cell proportions instead.]

The matrices and _b and _se variables work the same way after
regression or other estimation commands.

On Thu, Feb 28, 2008 at 12:50 AM, Adrian de la Garza
<> wrote:
>  (a) Suppose I create the following table:
>  tab jobclass sex, row nofreq
>             |         1          2 |     Total
>  -----------+----------------------+----------
>          1 |     97.35       2.65 |    100.00
>          2 |     73.53      26.47 |    100.00
>  -----------+----------------------+----------
>      Total |     77.61      22.39 |    100.00
>  is there a way for me to save one of the values in the table to a variable or scalar? For example, suppose I want to create a variable x equal to the value contained in cell (2,1), x = 73.53. How can I do this?
>  (b) Now, is there a way to save the whole table above to a matrix? Hopefully, without having to do (a) repeatedly many times?
>  And one more question: if I do something like
>  reg depvar var1 var2 var3 var4
>  I will obtain the regression output that Stata provides. Can I save the stuff in the regression output to other variables? For instance, if I want the estimate and the standard errors of the coefficient of var3, and I want to put them in a scalar x1 and x2, respectively, how do I do this?
*   For searches and help try:

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