Hi,

I would like to create average variables which are the average of the last three years. For example, average_2009 = (yr2009+yr2008+yr2007)/3 ; average_2010 =
(yr20010+yr2009+yr2008)/3, and so on.

The structure of my data is as follows

Could you please help?

Cheers,
Anh Tuan


country serie yr2007 yr2008 yr2009 yr2010 yr2011 yr2013 yr2014
Afghanistan GDP 6.97E+09 9.75E+09 1.24E+10 1.59E+10 1.78E+10 2.06E+10 2.05E+10
Afghanistan GDP per capita 365.28449 405.549 488.3003 543.303 528.7367 587.5651 583.6562
Afghanistan GDP growth 5.3574032 13.82632 21.39053 14.36244 0.426355 5.600745 2.724543
Afghanistan Inflation, 6.7845965 8.680571 -6.81116 2.178538 11.80419 7.385772 4.673996
Albania GDP 8.90E+09 1.07E+10 1.20E+10 1.19E+10 1.29E+10 1.28E+10 1.32E+10
Albania GDP per capita 3263.9111 3485.333 3928.459 4094.359 4209.887 4327.393 4413.115
Albania GDP growth 5.900084 5.979982 3.349994 3.706881 2.545405 1.001988 1.77
Albania Inflation, 2.3707283 2.932683 2.231397 3.615385 3.442836 1.925444 1.613042