Dear All,
I have the following dataset (example for 2 countries only)
I would generate the growth rate of the variable KOFGI using a rolling window over 5 years. I tried the following:
I run everything, but at the end the variable rkof does not show up at all. I am sure I am making a mistake in the code. Any hint about?
Thanks in advance,
Dario
I have the following dataset (example for 2 countries only)
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float id int year float KOFGI 1 1970 18.34902 1 1971 18.884224 1 1972 18.59799 1 1973 18.547972 1 1974 18.25414 1 1975 18.986671 1 1976 18.041212 1 1977 19.2219 1 1978 17.466097 1 1979 18.411556 1 1980 19.13836 1 1981 19.69164 1 1982 19.90187 1 1983 20.342705 1 1984 20.47284 1 1985 20.522293 1 1986 20.94291 1 1987 21.479084 1 1988 22.152985 1 1989 21.926537 1 1990 22.432707 1 1991 22.645435 1 1992 23.23357 1 1993 23.404493 1 1994 23.599314 1 1995 23.688236 1 1996 23.70481 1 1997 24.139524 1 1998 24.408384 1 1999 24.375294 1 2000 24.294 1 2001 24.2185 1 2002 24.9463 1 2003 25.81677 1 2004 27.24133 1 2005 31.655056 1 2006 32.122574 1 2007 33.30513 1 2008 36.267826 1 2009 35.98519 1 2010 37.13828 1 2011 37.94497 1 2012 38.35154 1 2013 38.96558 1 2014 38.16883 1 2015 38.65878 2 1970 32.352722 2 1971 33.23895 2 1972 28.809397 2 1973 29.616055 2 1974 31.840567 2 1975 31.43512 2 1976 34.001904 2 1977 32.496044 2 1978 28.450764 2 1979 33.879417 2 1980 34.50627 2 1981 33.457706 2 1982 32.067017 2 1983 33.50897 2 1984 33.22702 2 1985 31.079716 2 1986 32.47196 2 1987 33.614937 2 1988 32.27095 2 1989 33.805332 2 1990 29.19638 2 1991 32.818542 2 1992 39.27695 2 1993 41.3872 2 1994 39.91748 2 1995 43.01009 2 1996 39.7592 2 1997 43.18169 2 1998 45.02961 2 1999 45.71342 2 2000 48.72862 2 2001 53.70942 2 2002 55.58897 2 2003 55.25804 2 2004 53.04132 2 2005 56.60674 2 2006 59.30991 2 2007 61.91549 2 2008 63.61581 2 2009 65.83179 2 2010 66.71543 2 2011 63.43282 2 2012 60.50565 2 2013 63.60769 2 2014 66.34361 2 2015 67.185555 end
Code:
program rolling tsset id year gen lnKOFGI=ln(KOFGI) gen rkof=(lnKOFGI-L5.lnKOFGI)/4 end rangerun rolling, interval (year -4 0) use (id year rkof)
Thanks in advance,
Dario
Comment