Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: help creating a table of means and diffs with svy data


From   Austin Nichols <[email protected]>
To   [email protected]
Subject   Re: st: help creating a table of means and diffs with svy data
Date   Tue, 26 Jan 2010 15:10:08 -0500

Sergio I Prada <[email protected]>:
Did you mean sd or SE in parentheses?  I will assume you want the
standard deviations, since that is harder.  A simple method requires
editing the tables you get into one table.  A more complex method
would be to create a -program- that posts the info where -esttab- or
an alternative looks for it.  A better way might be to use -file- to
write out the info in exactly the way you need to save it.  Here's the
simple method I had in mind:

ssc inst estout
clear all
webuse nhanes2f
svyset psuid [pw=finalwgt], strata(stratid)
g male=1-female
la var male "Male"
la var female "Female"
svy: reg height male female, nocons
est sto Height
su height [aw=finalwgt] if female==0
mat sd=r(sd)
su height [aw=finalwgt] if female==1
mat sd=sd,r(sd)
mat rownames sd=y1
mat colnames sd=male female
estadd matrix sd=sd
svy: reg weight male female, nocons
est sto Weight
su weight [aw=finalwgt] if female==0
mat sd=r(sd)
su weight [aw=finalwgt] if female==1
mat sd=sd,r(sd)
mat rownames sd=y1
mat colnames sd=male female
estadd matrix sd=sd
esttab Height Weight using twoparts.doc, mti nogaps rtf nostar aux(sd) la
la var female "Difference"
svy: reg height female
est sto Height
svy: reg weight female
est sto Weight
esttab Height Weight using twoparts.doc, mti nogaps rtf la a

On Tue, Jan 26, 2010 at 11:54 AM, Sergio I Prada <[email protected]> wrote:
> Hi, I am looking for help in automating a rather tedious task.
>
> I want to have a table comparing the means for some variables for two
> subpopulations in my survey data, including a test on the diff btw the
> means.
>
> For instance, according to the SVY Manual the right way to get the numbers
> is:
>
> use http://www.stata-press.com/data/r11/nhanes2f
> svyset psuid [pweight=finalwgt], strata(stratid)
> svy: mean height, over(sex)
> lincom [height]Male - [height]Female
> svy: mean weight, over(sex)
> lincom [weight]Male - [weight]Female
>
>
> The table I'd like to have looks like
>
>                  Male       Female     Diff
>                mena/sd   mean/sd
>
> Height      175.58       161.90      13.67***
>                 (0.17)       (0.13)
> Weight       78.63      65.71        12.92***
>                 (0.21)      (0.27)

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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