Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Constructing new variable by country isic year

    Hi,

    I am trying to construct a new variable by iteration as follows:

    For the first observation by country industry year I need to calculate:

    K= [(GrossFixed/OutputINDSTAT4)*OutputINDSTAT4]/ (pl_i/pl_gdpo)

    For all the remaining observations by country industry year, I do the following

    xtset country_industry year (country_industry is a group variable country isic)

    bysort country_industry year: replace k= 0.95*L.k + GrossFixed if _n>1 (replace observations after the first observation by this equation). However, I get no changes. Any advice?


    Code:
     * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float country1 int year str2 isic float inv_rate1 str3 isiccomb byte sourcecode float country_industry double GrossFixed float(rgdpo pl_i) double OutputINDSTAT4
    8 2000 "15"    .7002312 "15" 2 24 32574268 16633.271  .4704611  46519304
    8 2001 "15"   .53158116 "15" 2 24 30241796 17293.777 .45783275  56890271
    8 2002 "15"   .09306718 "15" 2 24  7384707 17619.768  .4317585  79348139
    8 2003 "15"    .1654968 "15" 2 24 19743819 18275.127  .4735264 119300314
    8 2004 "15"   .09079189 "15" 2 24 15461755 18750.121  .5309684 170298865
    8 2005 "15"   .20347802 "15" 2 24 42143630 20162.416 .50548273 207116365
    8 2006 "15"     .160166 "15" 2 24 35969669 21773.834  .4675638 224577417
    8 2007 "15"   .12287953 "15" 2 24 37276617  23260.23 .50702834 303359039
    8 2008 "15"   .10242119 "15" 2 24 35053315  25868.79   .538296 342246719
    8 2009 "15"   .05309422 "15" 2 24 16348092   27709.9  .4574546 307907211
    8 2010 "15"   .12594055 "15" 2 24 41019306 31021.064  .4342498 325703729
    8 2011 "15"  .071222536 "15" 2 24 24383148 31369.516  .4911933 342351591
    8 2012 "15"   .04863698 "15" 2 24 18635989  32366.19  .4482535 383165043
    8 2013 "15"   .06240315 "15" 2 24 23391942  30914.69  .4837263 374851957
    8 2014 "15"   .04335002 "15" 2 24 14516013 32090.506  .4465655 334855982
    8 2000 "16"   .03108056 "16" 1 25   263372 16633.271  .4704611   8473850
    8 2001 "16"   .10536187 "16" 1 25   749661 17293.777 .45783275   7115107
    8 2002 "16"   .10725082 "16" 1 25   506584 17619.768  .4317585   4723358
    8 2003 "16"  .017762735 "16" 1 25    85481 18275.127  .4735264   4812378
    8 2004 "16"   .07810422 "16" 1 25   201206 18750.121  .5309684   2576122
    8 2005 "16"   .04216438 "16" 1 25   236597 20162.416 .50548273   5611300
    8 2006 "16" .0003355177 "16" 2 25     1865 21773.834  .4675638   5558575
    8 2007 "16"  .012659497 "16" 1 25    61906  23260.23 .50702834   4890084
    8 2009 "16"  .023686197 "16" 1 25    62836   27709.9  .4574546   2652853
    8 2012 "16"   .02461316 "16" 1 25    77035  32366.19  .4482535   3129830
    8 2013 "16"  .012220494 "16" 1 25    66244  30914.69  .4837263   5420730
    8 2014 "16"    .0268095 "16" 1 25   167065 32090.506  .4465655   6231560
    8 2015 "17"   .11613289 "17" 3 26  1471835  33659.42  .3907649  12673714
    8 2016 "17"   .27857697 "17" 3 26  3079267 33697.977  .3953842  11053559
    8 2017 "17"    .2260792 "17" 3 26  4265323 34974.945  .4131873  18866499
    8 2018 "17"    .1649155 "17" 3 26  3342928  35363.47  .4607996  20270552
    8 2015 "18"   .11506865 "18" 3 27 14846257  33659.42  .3907649 129020866
    8 2016 "18"   .08041292 "18" 3 27 13371415 33697.977  .3953842 166284400
    8 2017 "18"    .1245501 "18" 3 27 24987406 34974.945  .4131873 200621327
    8 2018 "18"   .12672547 "18" 3 27 29669643  35363.47  .4607996 234125336
    8 2000 "19"  .036778778 "19" 1 28  1151261 16633.271  .4704611  31302319
    8 2001 "19"    .1673024 "19" 1 28  6447915 17293.777 .45783275  38540478
    8 2002 "19"   .16318914 "19" 1 28  6863853 17619.768  .4317585  42060721
    8 2003 "19"   .17775865 "19" 1 28  9643096 18275.127  .4735264  54248250
    8 2004 "19"   .07645959 "19" 1 28  4710408 18750.121  .5309684  61606508
    8 2005 "19"   .07961106 "19" 1 28  5100588 20162.416 .50548273  64068837
    8 2006 "19"   .08865269 "19" 1 28  6438066 21773.834  .4675638  72621221
    8 2007 "19"   .06368916 "19" 1 28  6448773  23260.23 .50702834 101253856
    8 2008 "19"   .07240916 "19" 1 28  7827905  25868.79   .538296 108106560
    8 2009 "19"   .08367565 "19" 1 28 10300436   27709.9  .4574546 123099573
    8 2010 "19"   .04144328 "19" 1 28  5782695 31021.064  .4342498 139532760
    8 2011 "19"  .027893614 "19" 1 28  4678508 31369.516  .4911933 167726848
    8 2012 "19"   .06224887 "19" 1 28  8368415  32366.19  .4482535 134434820
    8 2013 "19"    .0816324 "19" 1 28 13012651  30914.69  .4837263 159405487
    8 2014 "19"   .05166538 "19" 1 28  9566069 32090.506  .4465655 185154323
    8 2015 "19"   .16991568 "19" 3 28 27185890  33659.42  .3907649 159996364
    8 2016 "19"   .11248256 "19" 3 28 21274957 33697.977  .3953842 189140044
    8 2017 "19"   .10986374 "19" 3 28 23828715 34974.945  .4131873 216893367
    8 2018 "19"   .11918778 "19" 3 28 29623342  35363.47  .4607996 248543449
    8 2000 "20"   .04682928 "20" 1 29   584047 16633.271  .4704611  12471834
    8 2001 "20"   .11593734 "20" 1 29  1014058 17293.777 .45783275   8746604
    8 2002 "20"    .3043478 "20" 1 29  2746968 17619.768  .4317585   9025753
    8 2003 "20"   .06013104 "20" 1 29   799421 18275.127  .4735264  13294648
    8 2004 "20"   .08497558 "20" 1 29  1722542 18750.121  .5309684  20271025
    8 2005 "20"   .05960576 "20" 1 29   779752 20162.416 .50548273  13081823
    8 2006 "20"   .07845259 "20" 1 29  1653654 21773.834  .4675638  21078388
    8 2007 "20"   .02767088 "20" 1 29   876389  23260.23 .50702834  31671887
    8 2008 "20"   .06900739 "20" 1 29  2075926  25868.79   .538296  30082662
    8 2009 "20"    .0818771 "20" 1 29  2353932   27709.9  .4574546  28749579
    8 2010 "20"    .1332142 "20" 1 29  3328296 31021.064  .4342498  24984542
    8 2011 "20"   .04517043 "20" 1 29  1393041 31369.516  .4911933  30839668
    8 2012 "20"   .05669746 "20" 1 29  1789042  32366.19  .4482535  31554183
    8 2013 "20"    .1609934 "20" 1 29  5647144  30914.69  .4837263  35076864
    8 2014 "20"   .04730071 "20" 1 29  1371834 32090.506  .4465655  29002399
    8 2015 "20"   .15300676 "20" 3 29  3678136  33659.42  .3907649  24039043
    8 2016 "20"   .03939001 "20" 3 29  1225278 33697.977  .3953842  31106310
    8 2017 "20"   .23143594 "20" 3 29  8295550 34974.945  .4131873  35843829
    8 2018 "20"   .08442421 "20" 3 29  4120784  35363.47  .4607996  48810452
    8 2015 "21"     .168992 "21" 3 30  7126341  33659.42  .3907649  42169699
    8 2016 "21"    .0579945 "21" 3 30  2631275 33697.977  .3953842  45371109
    8 2017 "21"    .1836255 "21" 3 30  7212427 34974.945  .4131873  39277918
    8 2018 "21"   .16950053 "21" 3 30  8862000  35363.47  .4607996  52283022
    8 2015 "22"   .06647544 "22" 3 31  3972631  33659.42  .3907649  59760883
    8 2016 "22"   .20703307 "22" 3 31 11936850 33697.977  .3953842  57656732
    8 2017 "22"    .1549045 "22" 3 31  8035264 34974.945  .4131873  51872376
    8 2018 "22"   .11880397 "22" 3 31  6880320  35363.47  .4607996  57913216
    8 2000 "23"   .02741674 "23" 1 32  1124777 16633.271  .4704611  41025189
    8 2001 "23"  .013490294 "23" 1 32   498262 17293.777 .45783275  36934852
    8 2002 "23"  .004325114 "23" 1 32   171240 17619.768  .4317585  39592017
    8 2003 "23"   .01418813 "23" 1 32  1881240 18275.127  .4735264 132592525
    8 2004 "23"   .14084226 "23" 1 32 14992219 18750.121  .5309684 106446882
    8 2015 "23"  .017409204 "23" 3 32   340740  33659.42  .3907649  19572405
    8 2016 "23"  .030245807 "23" 3 32   308162 33697.977  .3953842  10188586
    8 2017 "23"  .036440663 "23" 3 32   361041 34974.945  .4131873   9907641
    8 2015 "24"   .09437454 "24" 3 33  4048851  33659.42  .3907649  42901941
    8 2016 "24"    .4725628 "24" 3 33 18937914 33697.977  .3953842  40074914
    8 2017 "24"   .08376069 "24" 3 33  4114190 34974.945  .4131873  49118388
    8 2018 "24"    .1387365 "24" 3 33  7259987  35363.47  .4607996  52329323
    8 2015 "25"   .13131227 "25" 3 34  5047710  33659.42  .3907649  38440507
    8 2016 "25"   .15836297 "25" 3 34  7389056 33697.977  .3953842  46658990
    8 2017 "25"    .2127201 "25" 3 34  9941226 34974.945  .4131873  46733837
    8 2018 "25"    .1526893 "25" 3 34  7991542  35363.47  .4607996  52338583
    8 2000 "26"    .2676634 "26" 1 35  7393392 16633.271  .4704611  27621976
    8 2001 "26"   .12615499 "26" 1 35  6206893 17293.777 .45783275  49200538
    8 2002 "26"   .25097418 "26" 1 35 14705199 17619.768  .4317585  58592475
    end






  • #2
    Code:
    bysort country_industry year: replace ...
    should be
    Code:
    bysort country_industry (year): replace ...

    Comment


    • #3
      Thank you very much!

      Comment

      Working...
      X