![]() |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Re: svy: mean and descriptive tables
From
"Michael Blasnik" <[email protected]>
To
<[email protected]>
Subject
st: Re: svy: mean and descriptive tables
Date
Thu, 19 Jul 2007 10:30:42 -0400
...
You need to learn more about returned results from commands. Try typing ereturn
list after svy:mean and see what is stored. You almost have the loop you need:
foreach var of varlist var1 var2 var3 {
qui svy: mean `var'
mat b=e(b)
local sd= sqrt(e(N) * el(e(V_srs), 1, 1))
noi di "`var' " _col(15) b[1,1] _col(30) `sd'
}
You may want to add some numeric formats to the display statement
Michael Blasnik
----- Original Message -----
From: "Claire Kamp Dush" <[email protected]>
To: <[email protected]>
Sent: Wednesday, July 18, 2007 10:52 PM
Subject: st: svy: mean and descriptive tables
<snip>
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
program:
prog svymean
local mean = svy: mean `1'
local sd = di sqrt(e(N) * el(e(V_srs), 1, 1))
display e(varlist) `mean' `sd'
end
*
* 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 |