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 |
Nick Cox <n.j.cox@durham.ac.uk> |

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

Subject |
RE: st: how to generate mean for a secquence of five year of a variable |

Date |
Fri, 6 May 2011 12:11:07 +0100 |

Have you thought about ignoring what you don't want or replacing it with missing? Nick n.j.cox@durham.ac.uk prakash singh Thanks Nick, Your suggestion did work but it is giving me five observation in place of one only. i.e. it is filling first four observation point with the mean value in stead of giving only one observation for var2 at cell number 5. On 5/5/11, Nick Cox <njcoxstata@gmail.com> wrote: > Here is one way to do it. > > bysort countryid (yearid) : gen order = _n > by countryid : egen first5 = mean(var1) if order <= 5 > by countryid : replace order = _N - order + 1 > by countryid (yearid) : egen last5 = mean(var1) if order <= 5 > gen var2 = min(first5, last5) > > On Thu, May 5, 2011 at 6:36 PM, prakash singh <prakashbhu@gmail.com> wrote: >> Thank Nick and Oliver for generating discussion which helped me coming >> across the command lowess thanks a lot but what I mean (let me try >> again to put my query in a better way) is: mean of only firs five >> observation and then mean of last five obesrvation for each country. >> the excercise is purely related to understanding the behaviour of the >> variable at both ends not an ecoonmetric excercise. >> * * 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 generate mean for a secquence of five year of a variable***From:*Scott Merryman <scott.merryman@gmail.com>

**References**:**st: how to generate mean for a secquence of five year of a variable***From:*prakash singh <prakashbhu@gmail.com>

**Re: st: how to generate mean for a secquence of five year of a variable***From:*Oliver Jones <ojones@wiwi.uni-bielefeld.de>

**Re: st: how to generate mean for a secquence of five year of a variable***From:*prakash singh <prakashbhu@gmail.com>

**Re: st: how to generate mean for a secquence of five year of a variable***From:*Oliver Jones <ojones@wiwi.uni-bielefeld.de>

**RE: st: how to generate mean for a secquence of five year of a variable***From:*Nick Cox <n.j.cox@durham.ac.uk>

**Re: st: how to generate mean for a secquence of five year of a variable***From:*Oliver Jones <ojones@wiwi.uni-bielefeld.de>

**RE: st: how to generate mean for a secquence of five year of a variable***From:*Nick Cox <n.j.cox@durham.ac.uk>

**Re: st: how to generate mean for a secquence of five year of a variable***From:*prakash singh <prakashbhu@gmail.com>

**Re: st: how to generate mean for a secquence of five year of a variable***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: how to generate mean for a secquence of five year of a variable***From:*prakash singh <prakashbhu@gmail.com>

- Prev by Date:
**Re: st: Stumped...xtmixed and ANOVA F-stats not agreeing for balanced design** - Next by Date:
**Re: st: running mean similar to lowess** - Previous by thread:
**Re: st: how to generate mean for a secquence of five year of a variable** - Next by thread:
**Re: st: how to generate mean for a secquence of five year of a variable** - Index(es):