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

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

From |
Nick Cox <n.j.cox@durham.ac.uk> |

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

Subject |
st: RE: correct egen command to calculate means - please help |

Date |
Wed, 18 May 2011 18:44:25 +0100 |

I don't understand your pseudocode. It looks like Y = mean(X) where A = B to me. Nor is it "obvious" that egen MeanRevenueParent=mean(Revenue), by(ParentIndustry) is wrong. From your word description it sounds exactly right to me! Please give a worked example of what you want for a minimal dataset. Note that explanations that assume proficiency in Excel _and_ Stata catch a much smaller set of people than explanations that assume proficiency in Stata. (Can we assume that income == revenue?) Nick n.j.cox@durham.ac.uk Ophelie Desmarais I have tried to find an answer for this on the web but to no avail. Simplified, I have following dataset where the unit of observation is the industry (IndustryID) with the respective revenue. IndustryID, ParentIndustryID, Revenue The ParentIndustryID links to IndustryID and reflects the hierachical structure of the industries. For each industry, I want to add a variable reflecting the mean income of the ParentIndustryID. How do I do this in Stata? In Excel, this would be simply using AVERAGEIFS. egen MeanRevenueParent=mean(Revenue), by(ParentIndustry) obviously does not give the right mean. In terms of pseudo code, this should be something like: MeanRevenueParent = Mean(Revenue) WHERE ParentIndustry=IndustryID Could anyone help me out? I don't want to switch around with Excel all the time. * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: RE: correct egen command to calculate means - please help***From:*Ophelie Desmarais <ophelie.desmarais@googlemail.com>

**References**:**st: correct egen command to calculate means - please help***From:*Ophelie Desmarais <ophelie.desmarais@googlemail.com>

- Prev by Date:
**Re: st: RE: using loop to generate distributions with different means and standard deviations** - Next by Date:
**Re: st: RE: correct egen command to calculate means - please help** - Previous by thread:
**st: correct egen command to calculate means - please help** - Next by thread:
**Re: st: RE: correct egen command to calculate means - please help** - Index(es):