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

Re: st: svy: mean and descriptive tables

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

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 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)
webuse nhanes2, clear
msd_tab smsa height weight bpsystol bpdiast tcresult tgresult

On 7/19/07, Claire Kamp Dush <> 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:

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