Statalist


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

RE: st: svy: mean and descriptive tables


From   "Claire Kamp Dush" <ckamp-dush@ehe.osu.edu>
To   "Austin Nichols" <austinnichols@gmail.com>, <statalist@hsphsun2.harvard.edu>
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
http://www.people.cornell.edu/pages/klp27/ 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 [mailto:austinnichols@gmail.com] 
Sent: Thursday, July 19, 2007 3:09 PM
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: svy: mean and descriptive tables

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 <ckamp-dush@ehe.osu.edu> 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index