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

Re: st: get summary files from svytab


From   [email protected]
To   [email protected]
Subject   Re: st: get summary files from svytab
Date   Mon, 08 Nov 2004 13:17:38 -0600

----- Original Message -----
From: Markus Steiner <[email protected]>
Date: Monday, November 8, 2004 8:24 am
Subject: st: get summary files from svytab

> Hello all,
> 
> I am quite new to Stata but experienced to SAS, and I have tried 
> severalfaq and the online help. The problem I am struggling in 
> Stata now is how
> to get the output from procedures like svytab into a file for further
> usage.
> What I am trying here is to get the counts (plus percentages at 
> the same
> time if possible) from svytab for further usage.
> 
> svytab dmethn sex if age >= 16, count format(%9.1f)
> 
> pweight:  scalewt               Number of obs      =     13947
> Strata:   samp                  Number of strata   =         8
> PSU:      area                  Number of PSUs     =       716
>                                Population size    = 101246.44
> 
> -------------------------------------
> derived   |            sex           
> ethnicity |     men    women    Total
> ----------+--------------------------
> caribbea |   367.2    503.1    870.2
>   indian |   595.4    616.2   1211.7
> pakistan |   357.8    369.8    727.6
> banglade |   136.6    138.7    275.4
>  chinese |    95.5    112.9    208.4
>    irish |  1546.3   1988.2   3534.5
>   core99 | 42975.6  51443.1  94418.7
>          | 
>    Total | 46074.4  55172.0  101246.4
> -------------------------------------
>  Key:  weighted counts
> 
>

Markus,


The saved results will be in -ereturn list-  see  [P] return, [R] saved results 
for more information.

Here, as an example, is one way to get the counts and percentage using the marix 
of cell proportions (e(Prop)) and the scalar containing the weighted total 
(e(total)) and then using -svmat- to to variables:

use http://www.stata-press.com/data/r8/nmihs.dta, clear
svyset [pweight=finwgt], strata(stratan)
svytab ageg mar , count format(%9.1f)
matrix counts = e(Prop)*e(total)
matrix percent = e(Prop)
svmat counts
svmat percent
keep counts* percent* 
keep in 1/5
l


One other point, the -svytab- helpfile does warn:

Warning:  Use of if or in restrictions will not produce correct statistics
and variance estimates for subpopulations in many cases.  To compute
estimates for subpopulations, use the subpop() option.


Hope this helps,
Scott


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