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: Panel Data 5 Year Average


From   Roberto Ferrer <[email protected]>
To   Stata Help <[email protected]>
Subject   Re: st: Panel Data 5 Year Average
Date   Wed, 8 Jan 2014 07:57:42 -0430

Do you want something like:



. bysort country: egen dum = seq(), block(5)

. bysort country dum: gen year2 = year[1]

. collapse y5=y l5=l, by(country year2)

. list, sepby(country)

     +---------------------------------+
     | country   year2      y5      l5 |
     |---------------------------------|
  1. |       1    1981    22.6    8.92 |
  2. |       1    1986    24.2    9.46 |
  3. |       1    1991    26.6    9.98 |
  4. |       1    1996    28.4   10.48 |
  5. |       1    2001    30.6   10.98 |
     |---------------------------------|
  6. |       2    1980   .2348   .0906 |
  7. |       2    1985   .2408   .0938 |
  8. |       2    1990   .2462   .1076 |
  9. |       2    1995   .2496   .1196 |
 10. |       2    2000   .2536    .129 |
 11. |       2    2005   .1285    .067 |
     +---------------------------------+

On Wed, Jan 8, 2014 at 4:55 AM, Nick Cox <[email protected]> wrote:
> <>
>
> This looks like the same question, so the answer is the same. Ignore
> results you don't want. The Stata way to do that is through -drop- or
> -keep-.
>
> Nick
> [email protected]
>
>
> On 8 January 2014 03:09, Muhammad Ramzan <[email protected]> wrote:
>> Thanks
>>
>> but in the second file there is no data for the periods of 1976 to
>> 1979. so it should take average from 1980-84 , 1985-89 ,1990-94,
>> 1995-99, 2000-2004 , 2005-2009 for the second country.
>> Regards
>> MUHAMMAD RAMZAN
>> *
>> *   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/
*
*   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/


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