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

st: svy: mean and descriptive tables

From   "Claire Kamp Dush" <>
To   <>
Subject   st: svy: mean and descriptive tables
Date   Wed, 18 Jul 2007 22:52:37 -0400

Dear Statalisters,

I am running several svy: mean commands for a descriptive statistic
table I am creating.  Here is the code I am running:

After svy setting the variables

foreach var of varlist var1 var2 var3 {
svy: mean `var'
di sqrt(e(N) * el(e(V_srs), 1, 1))

I am using Stata 9.  This code is working fine, and the first line
calculates the weighted mean and the second the standard deviation.  My
question is:  
Is there a way for me to write a code to create a table for my means and
standard deviations automatically?  For instance, I would like a table
as follows:

Var 1		mean1		sd1
Var 2		mean2		sd2
Var 3		mean3		sd3

Any suggestions on how I could do this?  Here is my first attempt at a

prog svymean 
	local mean = svy: mean `1'
	local sd = di sqrt(e(N) * el(e(V_srs), 1, 1))
	display e(varlist)	`mean'	`sd'

Then I thought I would run this for each of my variables and copy and
paste the results into a text file and then convert into an excel or
word file.  But, this didn't work because it wouldn't calculate the svy:
mean of `1'.  
I searched Statalist and I did not see a ready solution, but I could
have missed something.

In advance, I never know whether to e-mail thank yous and fill up
everyone's in boxes that much more, so in advance, a whole-hearted thank
you to anyone who replies.  I really appreciate it.


Claire M. Kamp Dush, Ph.D.
Department of Human Development and Family Science
The Ohio State University
171A Campbell Hall
Phone:  (614) 247-2126

*   For searches and help try:

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