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

RE: st: svy: mean and descriptive tables

From   "Claire Kamp Dush" <>
To   "Austin Nichols" <>, <>
Subject   RE: st: svy: mean and descriptive tables
Date   Thu, 19 Jul 2007 15:29:51 -0400

Dear Austin, 
Thank you for this kind reply as well.  I am actually svyset'ing by 3
different weights (by census sampling unit, by high school id, and by an
individual weight), so I didn't try the summarize command, though it
certainly crossed my mind.  Similar to this, there is the outsum program written by one of my former
colleagues at Cornell, Kerry Paps, that also create output tables and
allows for some weights.
Thanks Austin, Claire

-----Original Message-----
From: Austin Nichols [] 
Sent: Thursday, July 19, 2007 3:09 PM
Subject: Re: st: svy: mean and descriptive tables

This horse may have died before I arrived on the scene, but let me add
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),
> 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
> 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