I would like to calculate the standard deviation of annual changes in log-sales over the recent five years (on a rolling five-year basis). I already calculated the annual changes in log-sales (see variable: SALE_change_log). My dataset looks like this:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str24 gvkey double(fyear sale) float(SALE_change SALE_change_log) "001013" 2010 1156.6 . . "001094" 2016 558.524 . . "001094" 2017 638.318 79.79401 4.3794484 "001094" 2018 711.359 73.04101 4.291021 "001161" 2010 6494 . . "001161" 2011 6568 74 4.304065 "001161" 2012 5422 -1146 . "001161" 2016 4272 -1150 . "001161" 2017 5329 1057 6.96319 "001161" 2018 6475 1146 7.044033 "001173" 2010 29.618 . . "001173" 2011 29.607 -.01100003 . "001173" 2012 31.021 1.4139997 .3464223 "001210" 2010 83.362 . . "001210" 2011 89.383 6.021 1.7952534 "001210" 2012 103.064 13.680997 2.616008 "001210" 2013 100.772 -2.292003 . "001210" 2014 112.181 11.408997 2.434402 "001210" 2015 148.212 36.031002 3.58438 "001210" 2016 148.472 .2599944 -1.3470953 "001210" 2017 194.519 46.047 3.8296626 "001210" 2018 249.834 55.315 4.0130444 "001234" 2010 108.569 . . "001234" 2011 117.704 9.135 2.2121131 "001239" 2010 1598.464 . . "001266" 2010 79.792 . . "001266" 2011 98.592 18.8 2.933857 "001266" 2012 127.187 28.595 3.353232 "001266" 2013 101.661 -25.526 . "001266" 2014 88.68 -12.981003 . "001266" 2015 153.119 64.439 4.165719 "001266" 2016 144.196 -8.923003 . "001266" 2017 129.829 -14.367 . "001266" 2018 81.281 -48.548 . "001266" 2019 122.251 40.97 3.71284 "001308" 2010 659.665 . . "001327" 2018 3868 . . "001327" 2019 3376.8 -491.2 . "001439" 2010 104.836 . . "001439" 2011 154.917 50.081 3.913642 "001468" 2010 1592.568 . . "001468" 2011 1695.144 102.576 4.630604 "001468" 2012 1872.72 177.57596 5.179399 "001491" 2010 315.9 . . "001491" 2011 530.476 214.576 5.368664 "001491" 2013 523.957 -6.519013 . "001554" 2015 102.987 . . "001562" 2010 85.589 . . "001562" 2011 102.636 17.047003 2.8359745 "001562" 2012 100.467 -2.1690016 . "001562" 2013 100.601 .13399713 -2.0099368 "001562" 2014 102.873 2.272002 .8206614 "001562" 2015 113.889 11.016 2.399349 "001562" 2016 106.286 -7.603 . "001562" 2017 112.703 6.416997 1.8589503 "001562" 2018 108.706 -3.997003 . "001585" 2010 229.62 . . "001585" 2011 304.429 74.809006 4.314938 "001585" 2012 366.19 61.76101 4.1232724 "001602" 2010 15053 . . "001602" 2011 15582 529 6.270988 "001602" 2012 17265 1683 7.428333 "001602" 2013 18676 1411 7.252054 "001602" 2014 20063 1387 7.234899 "001602" 2015 21662 1599 7.377134 "001602" 2016 22991 1329 7.192182 "001602" 2017 22849 -142 . "001602" 2018 23747 898 6.80017 "001602" 2019 23362 -385 . "001632" 2017 5107.503 . . "001632" 2019 5991.065 883.5621 6.783962 "001633" 2010 423.597 . . "001633" 2011 473.595 49.99802 3.911983 "001633" 2012 516.571 42.976 3.760642 "001633" 2013 550.363 33.792015 3.5202246 "001633" 2014 517.548 -32.814976 . "001633" 2015 540.291 22.743027 3.1242585 "001633" 2016 508.848 -31.443016 . "001633" 2017 486.372 -22.47599 . "001634" 2010 106.688 . . "001634" 2011 109.118 2.4299965 .8878898 "001634" 2012 105.79 -3.327996 . "001635" 2010 168.789 . . "001635" 2011 179.17 10.381 2.339977 "001635" 2012 147.346 -31.824 . "001635" 2013 158.374 11.028007 2.400438 "001659" 2010 3393.791 . . "001659" 2011 4576.331 1182.54 7.07542 "001659" 2012 5272.01 695.679 6.544888 "001659" 2013 5604.574 332.5642 5.806833 "001661" 2010 4174.635 . . "001661" 2011 6060.351 1885.7162 7.542063 "001661" 2015 3864.437 -2195.914 . "001661" 2016 2227.839 -1636.598 . "001661" 2017 2564.285 336.4459 5.818438 "001661" 2018 3057.619 493.3341 6.201187 "001661" 2019 3043.383 -14.235896 . "001678" 2010 12183 . . "001678" 2011 16810 4627 8.439664 "001678" 2012 16947 137 4.919981 end
Roy
0 Response to Standard deviation of annual changes in log-sales over the recent five years
Post a Comment