Announcement

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

  • Calculating growth & Index

    I want to develop variable by s_id which reflect the growth & index of other variable. How can I do it? Example data set as follows

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float year byte s_id double(gdp_curr gdp_const ndp_curr ndpconst pccurr pcconst)
    2000 1             128797             128797             116360             116360              15427              15427
    2001 1             144723             139312             130756             126035              17195              16574
    2002 1             156711             145185             142160             131750              18573              17213
    2003 1             167096             149142             151019             134749              19434              17340
    2004 1             190017             163085             172411             147950              21931              18819
    2005 1             134767             134767             121388             121388 25959.144584491238 25959.144483322725
    2006 1             147606             141977             133072             128150 28223.327367747326  27179.35098184143
    2007 1             174064             157386             156646             141610 32960.772650213694  29796.91783121268
    2008 1             212361             178028             190738             159270  39779.83250814583  33216.77533334601
    2009 1             237383             181829             214873             163341 44375.649807161455  33733.21598770161
    2010 1             273327             194994             246936             174401 50515.120638353736 35676.780849438044
    2011 1             319864             208273             289776             186041  58733.29929418745  37707.66967830897
    2012 1          379402.03          379402.03 339995.52419439546 339995.52419439546  68999.59902473779  68999.59902473779
    2013 1          411403.71 380629.01073573204   370196.056454919   341335.223157467  74687.49878039764  68864.79101752551
    2014 1          464272.01 407114.75244340533   413163.641514285 360239.22577487206  82869.73574709368  72254.49300496862
    2015 1          524975.64          444564.28 470933.80719736824  397063.8324905267  93903.17385443325  79173.66203874833
    2016 1  604228.6195319999          498606.26          544827.24          446996.86 108002.06953970583  88608.97989929827
    2017 1          684415.87          540211.77  612348.7454396419 477565.55262027937 120676.49635213563  94114.56804293781
    2018 1  786135.4155637296  594736.5326585321   705890.154562616  526625.9554962314  138298.6529579389 103177.04502189053
    2019 1  870849.2002510941  623732.3693002368  781850.0059903688  550817.2953933165 152285.69875740027 107286.04729033649
    2020 1  971224.2196229999  668847.8892626766  870064.3035423022  588343.1722201206 168479.97822359749 113927.26312306272
    2021 1  986610.5338362992  651624.1011290943  884198.8165547258   573757.608885687   170214.995679114 110452.70259224714
    2000 2               1612               1612               1497               1497              13990              13990
    2001 2               1787               1726               1665               1607              15260              14726
    2002 2               2104               1997               1961               1864              17664              16793
    2003 2               2071               1911               1920               1775              17124              15832
    2004 2               2368               2120               2193               1968              19322              17340
    2005 2               3488               3488               3188               3188              26721 26721.334285532277
    2006 2               3755               3584               3439               3281              28171  26869.65680709876
    2007 2               4108               3772               3765               3458              30132 27674.511291554023
    2008 2               4810               4227               4407               3873              34466 30287.020462808083
    2009 2               5687               4596               5199               4191              39726  32027.89978329375
    2010 2               7474               5029               6840               4539              51068  33892.62672019676
    2011 2               9021               5220               8356               4735              60961  34548.40072345185
    2012 2           11062.69           11062.69           10229.46           10229.46  73540.33069734003  73540.33069734003
    2013 2           12546.62           11299.17           11617.23            10398.7  82626.10241820768  73959.45945945945
    2014 2           14581.07           12338.34           13376.57           11225.36  94134.90499648136  78996.19985925405
    2015 2           17959.41           14382.65           16495.17            13081.6 114788.93528183716  91034.09881697982
    2016 2           18509.16           14240.46           16986.23           12889.06 116985.05509641873  88767.63085399449
    2017 2           19902.12           14893.71           18209.78           13396.43  124129.3796864349  91318.54124062712
    2018 2           22474.78           15574.01           20561.59           13923.28  138835.8541525996  94012.69412559082
    2019 2           25268.24           16619.94           23135.88           14846.59 154651.60427807487  99241.91176470587
    2020 2           28046.13            17916.4           25648.01           15933.64 169741.95896757115 105450.95962938451
    2021 2                  .                  .                  .                  .                  .                  .
    2000 3              34833              34833              32011              32011              12282              12282
    2001 3              36814              35715              33760              32821              12803              12447
    2002 3              38313              36642              35094              33668              13059              12529
    2003 3              43407              39233              39394              35708              14421              13072
    2004 3              47305              41595              42927              37905              15487              13675
    2005 3              53398              53398              47181              47181  16781.93782457139              16782
    2006 3              59385              55214              52440              48602 18396.014874061602              17050
    2007 3              64692              57784              57033              50797   19737.4965393134              17579
    2008 3              71076              60567              62342              52968   21290.0826446281              18089
    2009 3              81074              64033              71478              56123  24099.16048550236              18922
    2010 3              95975              69794              85253              61294  28382.69467656557              20406
    2011 3             112688              73444             100627              64310  33086.74251142603              21146
    2012 3          143174.91          143174.91          129354.12          129354.12  41141.85935561846  41141.85935561846
    2013 3          156864.24          147342.38          142039.46           132517.6 44599.177342376286 41609.394624466215
    2014 3          177745.22           154525.4          160441.53          138724.76  49733.89026658401  43002.09547427154
    end
    format %ty year

  • #2
    If I understand what you want for the growth variable, you're looking for
    Code:
    xtset s_id year, y
    
    foreach v of var gdp_curr-pcconst {
    
    
    
    bys s_id: g grow_`v' = D.`v'/L.`v'
    
    
    }
    
    br *grow*
    I don't know what you mean by the "index" of other variables, the code I've just given generates the growth rates.

    Comment

    Working...
    X