Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
"HUANG, LILING" <HUANGL@mailbox.sc.edu> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: use egen functions to get survey weighted means |

Date |
Sat, 1 Dec 2012 12:05:18 +0000 |

Thank you both so much for your prompt assistance! Austin's syntax works like a charm. And, Nick, I am sorry that I didn't make myself clear in the first place, your information are very helpful! Liling ________________________________________ From: owner-statalist@hsphsun2.harvard.edu [owner-statalist@hsphsun2.harvard.edu] on behalf of Nick Cox [njcoxstata@gmail.com] Sent: Saturday, December 01, 2012 6:51 AM To: statalist@hsphsun2.harvard.edu Subject: Re: st: use egen functions to get survey weighted means Austin has remembered what I had forgotten for the moment. David Kantor's function cited here subverts -egen-'s lack of support for weights by allowing them to be supplied as an option. But in general do not look to -egen- when working with -svy:-. The original question did not make clear (to me) that Liling wanted repeated calculation for different groups. In fact the background given in the second post made much more sense of the first. This FAQ may indicate some technique. FAQ . . Calculating variables containing weighted group summary statistics . . . . . . . . . . . . . . . . . . . . . N. J. Cox and S. P. Jenkins 1/03 I want to calculate a variable containing weighted group summary statistics, but I do not want to collapse the data and egen does not support weights. How can I do this? http://www.stata.com/support/faqs/data-management/weighted-group-summary-statistics/ For a single mean left in e(b) mat b = e(b) replace <whatever> = b[1,1] if <whatever> avoids use of -svmat-. On Fri, Nov 30, 2012 at 8:27 PM, Austin Nichols <austinnichols@gmail.com> wrote: > LILING <HUANGL@mailbox.sc.edu>: > ssc inst _gwtmean > egen m=wtmean(rank), by(x y z) weight(wt) > > On Fri, Nov 30, 2012 at 3:08 PM, HUANG, LILING <HUANGL@mailbox.sc.edu> wrote: >> 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. * * 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/

**References**:**Re: st: use egen functions to get survey weighted means***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**st: Need help converting values into factor variable** - Next by Date:
**Re: st: Bootstrapping Malmquist Poductivity Index** - Previous by thread:
**Re: st: use egen functions to get survey weighted means** - Next by thread:
**st: Need help converting values into factor variable** - Index(es):