Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: use egen functions to get survey weighted means


From   "HUANG, LILING" <[email protected]>
To   "<[email protected]>" <[email protected]>
Subject   Re: st: use egen functions to get survey weighted means
Date   Fri, 30 Nov 2012 20:08:25 +0000

Nick, Thank you very much for prompt response to my inquiry. But I do need a new variable to get the mean constants that result from a variety of conditions by the statement if x==1 & y==1 & z==1 (e.g., x==1 & y==2 & z==2). I was struggling with this and doing it in a hard way by generating each new variable for each if statement and trying to use replace command to collect all the means from these variables into one final variable. But when I tried to get weighted means and found that egen does not support svy:means.  Is there an easier way to get this done?  I looked up the past thread and learned to use the matrix means = e(b) and svmat means commands to get the weighted means. But I cannot quite figure out how to achieve what I want to get out of my data in an easy way. 

Liling

Sent from my iPad

On Nov 30, 2012, at 2:33 PM, "Nick Cox" <[email protected]> wrote:

> You are correct in your guess. -egen- does not support weights of any
> kind and it does not support -svy:-, or vice versa.
> 
> More positively, your example implies a single mean, so -svy: mean-
> should work. The result will be a constant, so no need to think that
> you are creating a new variable.
> 
> Nick
> 
> On Fri, Nov 30, 2012 at 7:16 PM, HUANG, LILING <[email protected]> wrote:
> 
>> I would like to creates a new variable that contains survey weighted mean estimates of one variable. The egen command does not seem to support such a function. Could you please let me know how to get this resolved?
>> 
>> . egen meanrank = svy:mean(rank) if x==1 & y==1 & z==1
>> unknown egen function svy:mean()
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index