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

From |
Joseph McDonnell <jockmcdock@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: how to express the mean of a variable in a calculation? |

Date |
Wed, 8 Jul 2009 09:45:58 +0930 |

quietly summarize x2 if year>=1 & year<=5 display r(mean) local x2mean1_5=r(mean) di `x2mean1_5' you can then use x2mean1_5 in your calculations. You can, in principle, use r(mean) but this will be wiped on the next r-class command. If you want the mean for each individual year, you could use a loop forvalues yr=1(1)5 { quietly summarize x2 if year==`yr' local mean`yr'=r(mean) } di `mean1' di `mean5' Cheers Joseph 2009/7/8 <jjc.li@utoronto.ca>: > Dear all, > > I am going to calculate sth after the the regression. I know _b[x1] > represents the coef. of variable x1. But how to express the mean of variable > x2, in particular just the mean of x2 from year 1 to year 5 (let's say there > are total 10 years)? > > Thanks! > > Crystal > > * > * 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/ > * * 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: how to express the mean of a variable in a calculation?***From:*jjc.li@utoronto.ca

**Re: st: how to express the mean of a variable in a calculation?***From:*jjc.li@utoronto.ca

**References**:**st: how to express the mean of a variable in a calculation?***From:*jjc.li@utoronto.ca

- Prev by Date:
**st: how to express the mean of a variable in a calculation?** - Next by Date:
**Re: st: reduce panel data set to survival data** - Previous by thread:
**st: how to express the mean of a variable in a calculation?** - Next by thread:
**Re: st: how to express the mean of a variable in a calculation?** - Index(es):

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