Statalist


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

Re: st: svy: mean and descriptive tables


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st: svy: mean and descriptive tables
Date   Thu, 19 Jul 2007 15:08:40 -0400

Claire--
This horse may have died before I arrived on the scene, but let me add to
Jeff's exhaustive comments that the mean and sd are also available
from -summarize- by treating your pweights as aweights (see
http://www.stata.com/support/faqs/stat/supweight.html for more).
So you could use r(mean) and r(sd) after -su- like so:

cap prog drop msd_tab
prog msd_tab
version 8
syntax varlist
local w: char _dta[pweight]
local k : list sizeof varlist
di as txt %12s "Variable"  _c
di as txt %10s "N"         _c
di as txt %12s "Mean"      _c
di as txt %12s "Std. Dev."
forval i = 1/`k' {
 local var : word `i' of `varlist'
 qui su `var' [aw=`w']
 di as txt %12s "`var'"     _c
 di " "  as res %9.0g r(N)  _c
 di "   " as res %9.0g r(mean)  _c
 di "   " as res %9.0g r(sd)
}
end
webuse nhanes2, clear
msd_tab smsa height weight bpsystol bpdiast tcresult tgresult


On 7/19/07, Claire Kamp Dush <[email protected]> wrote:
Dear Statalist,
Per Nick's message (st: "Thanks in advance" and closure of threads), let
me wrap up my thread and say that Jeff Pitblado and Michael Blasnik
along with Emma Slaymaker were so kind to reply to me and my original
problem is well-solved with these programs.  As a new programmer, it is
incredibly helpful to get this kind of help and it pushes me much
further on the path to programming these kinds of complicated programs
myself, so I thank you for your goodwill towards me and patience as I
try to learn.
Claire Kamp Dush
*
*   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