Dear all,
I have a dataset, and I want to calculate the following:
the time variable is Year and idenfier is stkcd
1- the growth of sales (i.e., annual percentage change in sales computed over a rolling prior five-year average)
2- the SD of Employees (i.e., standard deviation of the number of employees computed over a rolling prior five-year period)
Please note that the five years are previous four years and the current year (i.e., five years in total). Moreover, the codes work at least three years of non-missing observations of the 5 years.
I have a dataset, and I want to calculate the following:
the time variable is Year and idenfier is stkcd
1- the growth of sales (i.e., annual percentage change in sales computed over a rolling prior five-year average)
2- the SD of Employees (i.e., standard deviation of the number of employees computed over a rolling prior five-year period)
Please note that the five years are previous four years and the current year (i.e., five years in total). Moreover, the codes work at least three years of non-missing observations of the 5 years.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str10 stkcd int Year float Sales_ratio long Employees "000001" 1990 . . "000001" 1991 .14371508 . "000001" 1992 .1823193 . "000001" 1993 .3744477 . "000001" 1994 .3071169 . "000001" 1995 .24909584 . "000001" 1996 .3777668 . "000001" 1997 .8673497 . "000001" 1998 .7298861 . "000001" 1999 .951558 3724 "000001" 2000 1.1088568 4540 "000001" 2001 .8323369 5089 "000001" 2002 .7736639 5834 "000001" 2003 .7632429 6471 "000001" 2004 .72388 6999 "000001" 2005 .5304625 7142 "000001" 2006 .29376686 7737 "000001" 2007 .15102495 8573 "000001" 2008 .12349015 10381 "000001" 2009 .11994385 11308 "000001" 2010 .13622116 12203 "000001" 2011 .12116154 13778 "000001" 2012 .0908845 24251 "000001" 2013 .07201622 34724 "000001" 2014 .05396605 35069 "000001" 2015 .0516477 37937 "000001" 2016 .07964297 36885 "000001" 2017 .07662894 32502 "000001" 2018 .10261552 34626 "000001" 2019 .08746669 34253 "000001" 2020 .07604613 38097 "000001" 2021 .078005 40651 "000002" 1991 . . "000002" 1992 .14235453 . "000002" 1993 .15257035 . "000002" 1994 .24401517 . "000002" 1995 .16431734 . "000002" 1996 .20858665 . "000002" 1997 .12405314 . "000002" 1998 .09469618 . "000002" 1999 .131903 5263 "000002" 2000 .08940592 6616 "000002" 2001 .06471542 5349 "000002" 2002 .07622017 6055 "000002" 2003 .04200978 7025 "000002" 2004 .030183744 9627 "000002" 2005 .020523453 10961 "000002" 2006 .028407276 13402 "000002" 2007 .016190836 16464 "000002" 2008 .030867964 16515 "000002" 2009 .027740363 17616 "000002" 2010 .0240483 22850 "000002" 2011 .02223184 27951 "000002" 2012 .015635373 31019 "000002" 2013 .015727246 35330 "000002" 2014 .015768722 40647 "000002" 2015 .025147043 42295 "000002" 2016 .028322015 58280 "000002" 2017 .02922559 77708 "000002" 2018 .03874576 104300 "000002" 2019 .03370492 131505 "000002" 2020 .0300095 140565 "000002" 2021 .028315187 139494 "000003" 1991 .24541616 . "000003" 1992 .18424775 . "000003" 1993 .3568194 . "000003" 1994 .346334 . "000003" 1995 .4246282 . "000003" 1996 .5181839 . "000003" 1997 1.547955 . "000003" 1998 1.687041 . "000003" 1999 1.6189823 7763 "000003" 2000 1.4821774 5446 "000003" 2001 6.292617 2941 "000004" 1991 1.196615 . "000004" 1992 1.3790104 . "000004" 1993 1.245849 . "000004" 1994 1.4277534 . "000004" 1995 .55450624 . "000004" 1996 .8940032 . "000004" 1997 .6499602 . "000004" 1998 .9245127 . "000004" 1999 .6616528 417 "000004" 2000 .56364226 444 "000004" 2001 .7611679 375 "000004" 2002 .3726198 386 "000004" 2003 .3611042 344 "000004" 2004 .3621914 303 "000004" 2005 .53021955 284 "000004" 2006 .7428926 284 "000004" 2007 .7518347 284 "000004" 2008 .6660923 288 "000004" 2009 .4413795 291 "000004" 2010 .18553653 277 "000004" 2011 .4915147 322 "000004" 2012 .4778415 277 "000004" 2013 .5644544 243 "000004" 2014 .46919435 220 "000004" 2015 .313668 208 "000004" 2016 .1163322 179 end
Comment