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: how to generate mean for a secquence of five year of a variable


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: how to generate mean for a secquence of five year of a variable
Date   Thu, 5 May 2011 18:50:58 +0100

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 <[email protected]> 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.
>
> I render my sincere apology if due to capacity constraint I am not
> able to explain the query in a appropriate way.
>
> Prakash
>
>
*
*   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/


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