Announcement

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

  • Question (Percentage)- Final Period- Initial Value

    Dear all,

    I have data for value added and employment in the manufacturing sector (Source: GGDC 10-Sector Database). And I want to calculate average annual percentage change using the following set up:

    Percentage Change= ln_{t}- ln_{1970}/T

    ln_{t}= log of value added per worker in the last period of the data

    ln_{1970}= log of value added per worker in 1970

    T= Number of Years

    I am having a hard time writing a proper syntax (though I have been reading some posts here that were quite helpful). Is there this is done in a proper way? I deeply deeply appreciate your help!

    [/CODE]
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long NAMES_STD1 int Year double(MANVA_Q05 MANEMP) float(val_added_worker lval_added_worker)
    1 1950 40415.97471434924 1603.248665978112 25.2088 3.227193
    1 1951 41425.26497203469 1640.9270838315977 25.245037 3.2286296
    1 1952 38394.62142354514 1690.1174670723078 22.71713 3.123119
    1 1953 37586.313604102084 1578.124486009093 23.81708 3.170403
    1 1954 40819.54488187431 1721.9974505655446 23.704765 3.165676
    1 1955 44536.58083989712 1839.9442963516249 24.205397 3.186576
    1 1956 43852.174219054825 1870.1772947737677 23.44814 3.154791
    1 1957 46044.045422873045 1939.5803369397272 23.73918 3.167127
    1 1958 48480.76899535466 2042.998998311949 23.7302 3.1667485
    1 1959 42206.05829478758 1931.8564698776147 21.84741 3.0840824
    1 1960 45347.83868787829 2050.891651089046 22.11128 3.096088
    1 1961 49732.73870164993 2087.5120145697656 23.82393 3.1706905
    1 1962 47484.48087640702 1990.2595528005556 23.858437 3.172138
    1 1963 45300.00341500079 1927.1958107816658 23.50566 3.157241
    1 1964 52156.39252744371 2029.157051149406 25.70348 3.2466264
    1 1965 58789.55036645825 2094.2723683294635 28.07159 3.334758
    1 1966 58661.98963878489 2051.6871735379796 28.592073 3.3531296
    1 1967 59092.50709468248 1979.7032545300906 29.849174 3.396157
    1 1968 63477.407108454114 2005.6410809577756 31.649435 3.45472
    1 1969 71034.24128803199 2049.4972166956827 34.65935 3.5455675
    1 1970 75568.34179577872 2013.223105133852 37.536 3.6253004
    1 1971 83125.17597535657 2009.784508849519 41.36024 3.72232
    1 1972 87659.2764831033 2012.0141820570557 43.56792 3.774321
    1 1973 91139.92103918681 2004.7824964848992 45.46125 3.8168604
    1 1974 96474.38715231481 2068.4353947926643 46.64124 3.842485
    1 1975 94015.23610725581 1984.9228704706516 47.36468 3.857877
    1 1976 91177.75413218774 1982.9200293449796 45.98156 3.8282404
    1 1977 98290.37561635839 2038.0339045082706 48.22804 3.8759406
    1 1978 87961.94122711057 2079.3634866813672 42.30234 3.7448425
    1 1979 96928.38426832571 2029.6833240182743 47.75542 3.866093
    1 1980 93220.74115423675 2078.711716579112 44.84544 3.803222
    1 1981 82051.92622837452 1924.8147751697472 42.62848 3.7525225
    1 1982 79849.12501718079 1781.2045270458907 44.82872 3.802849
    1 1983 85735.08725792539 1895.7092666344713 45.22586 3.811669
    1 1984 88002.3921649081 2104.917812894767 41.80799 3.7330875
    1 1985 79287.94286381664 1939.1580247933905 40.88782 3.710832
    1 1986 88292.65879595853 2090.7399828331645 42.23034 3.743139
    1 1987 89147.33276516253 2100.2994592008563 42.44506 3.7482104
    1 1988 85131.9777022984 2097.5279195786206 40.58681 3.703443
    1 1989 78659.03182987407 2068.8762652915284 38.020172 3.638117
    1 1990 75749.91514979098 2081.923647772041 36.38458 3.594145
    1 1991 83503.25938362662 2105.2072629877307 39.6651 3.680472
    1 1992 93169.13819760557 2140.8637918976674 43.51941 3.773207
    1 1993 97497.33618504625 2041.900975272574 47.74832 3.865944
    1 1994 101884.36142181292 1977.5463018822375 51.5206 3.9419816
    1 1995 94584.76811425512 1732.2202927210528 54.6032 4.0000925
    1 1996 100687.26172185612 1693.1115230135135 59.46877 4.085451
    1 1997 109901.58957180413 1802.9865902154204 60.9553 4.110141
    1 1998 111933.40187743191 1774.277091568325 63.08677 4.144511
    1 1999 103058.35090501276 1674.4346463290058 61.54815 4.1198196
    1 2000 99118.20517743148 1614.1981893122017 61.40399 4.1174746
    1 2001 91821.13534435017 1558.8798759665858 58.902 4.075875
    1 2002 81761.92732222493 1456.1682231979585 56.14868 4.028003
    1 2003 94817.00792603305 1626.6699119328646 58.28903 4.065414
    1 2004 106172.34597537403 1833.8680433666236 57.8953 4.058636
    1 2005 114091.12203451614 1879.9724367204637 60.68766 4.1057405
    1 2006 124249.43895041167 1965.8034071789314 63.20543 4.14639
    1 2007 133692.06538691575 2058.3684560689817 64.9505 4.1736255
    1 2008 139769.61140272173 2080.601922405474 67.17749 4.2073383
    1 2009 139003.53673925626 1979.5619769869206 70.21934 4.2516236
    1 2010 152664.4759775696 2097.052975198907 72.79953 4.2877097
    1 2011 169423.55210595185 2163.602077878524 78.30624 4.360627
    2 1950 1876.5492454289868 117.17786841216812 16.014536 2.773497
    2 1951 1978.8063316717348 117.08795575486364 16.90017 2.827324
    2 1952 1990.3012734507795 115.31912204914569 17.259073 2.848338
    2 1953 1887.8047092543006 121.50604447254129 15.536715 2.743206
    2 1954 2225.229146059998 140.88023102922068 15.795184 2.759705
    2 1955 2358.1394103801977 139.4072409944698 16.915472 2.828229
    2 1956 2172.0650403319178 132.9934547621734 16.332119 2.793134
    2 1957 1535.293161363608 93.03642803680854 16.502066 2.8034856
    2 1958 1679.4588895091222 91.09551002822022 18.436243 2.9143186
    2 1959 1679.4588895091222 89.23672472001341 18.820267 2.9349344
    2 1960 1808.3564115030504 91.72401587925557 19.71519 2.9813895
    2 1961 1812.1475150911072 89.47989175934643 20.25201 3.008254
    2 1962 2005.4937980819993 97.34967877635661 20.60093 3.025336
    2 1963 2126.809112899814 98.38118116547682 21.61805 3.0735285
    2 1964 2316.348577883631 105.7407094118738 21.90593 3.0867574
    2 1965 2530.131462807239 110.92662087394112 22.809055 3.127158
    2 1966 2843.091974757264 120.69012244612864 23.55696 3.159421
    2 1967 2959.901179921709 125.82937529654227 23.523134 3.157984
    2 1968 3034.8353870083347 120.7028296215909 25.143034 3.224581
    2 1969 3270.65774460448 135.63049377714574 24.11447 3.182812
    2 1970 3446.9735259847753 137.75197718945867 25.02304 3.219797
    2 1971 3543.947205743938 141.6690901189019 25.01567 3.2195024
    2 1972 3733.4866707277556 149.18258302647425 25.02629 3.219927
    2 1973 3919.788400803991 154.53407544733676 25.365204 3.2333784
    2 1974 4363.186518385432 169.12793741855776 25.79814 3.2503026
    2 1975 4629.597992394448 176.09729334940593 26.29 3.269189
    2 1976 5015.242573652255 186.547089407307 26.88459 3.291553
    2 1977 5363.6268088948145 195.74580193084586 27.40098 3.310579
    2 1978 5607.682075294683 202.70465239466938 27.6643 3.320143
    2 1979 5764.175528558721 207.74629043878835 27.746225 3.3231
    2 1980 5836.833203288453 212.43402955692028 27.47598 3.313312
    2 1981 5384.473758969947 194.44809862683405 27.69106 3.3211095
    2 1982 4718.761726771142 171.9152240302023 27.44819 3.3123
    2 1983 4727.529641341565 166.88966916399892 28.327276 3.343825
    2 1984 4775.915540267235 167.15019802573653 28.5726 3.352448
    2 1985 4378.436746408045 158.2217371411401 27.67279 3.3204496
    2 1986 4462.543778768772 155.27145926516712 28.74027 3.358299
    2 1987 4574.578242724181 162.16060772421343 28.21017 3.3396826
    end
    label values NAMES_STD1 NAMES_STD1
    label def NAMES_STD1 1 "Argentina", modify
    label def NAMES_STD1 2 "Bolivia", modify
    [/CODE]




  • #2

    Code:
     input long NAMES_STD1 int Year double(MANVA_Q05 MANEMP) float(val_added_worker lval_added_worker)
    1 1950  40415.97471434924  1603.248665978112   25.2088  3.227193
    1 1951  41425.26497203469 1640.9270838315977 25.245037 3.2286296
    1 1952  38394.62142354514 1690.1174670723078  22.71713  3.123119
    1 1953 37586.313604102084  1578.124486009093  23.81708  3.170403
    1 1954  40819.54488187431 1721.9974505655446 23.704765  3.165676
    1 1955  44536.58083989712 1839.9442963516249 24.205397  3.186576
    1 1956 43852.174219054825 1870.1772947737677  23.44814  3.154791
    1 1957 46044.045422873045 1939.5803369397272  23.73918  3.167127
    1 1958  48480.76899535466  2042.998998311949   23.7302 3.1667485
    1 1959  42206.05829478758 1931.8564698776147  21.84741 3.0840824
    1 1960  45347.83868787829  2050.891651089046  22.11128  3.096088
    1 1961  49732.73870164993 2087.5120145697656  23.82393 3.1706905
    1 1962  47484.48087640702 1990.2595528005556 23.858437  3.172138
    1 1963  45300.00341500079 1927.1958107816658  23.50566  3.157241
    1 1964  52156.39252744371  2029.157051149406  25.70348 3.2466264
    1 1965  58789.55036645825 2094.2723683294635  28.07159  3.334758
    1 1966  58661.98963878489 2051.6871735379796 28.592073 3.3531296
    1 1967  59092.50709468248 1979.7032545300906 29.849174  3.396157
    1 1968 63477.407108454114 2005.6410809577756 31.649435   3.45472
    1 1969  71034.24128803199 2049.4972166956827  34.65935 3.5455675
    1 1970  75568.34179577872  2013.223105133852    37.536 3.6253004
    1 1971  83125.17597535657  2009.784508849519  41.36024   3.72232
    1 1972   87659.2764831033 2012.0141820570557  43.56792  3.774321
    1 1973  91139.92103918681 2004.7824964848992  45.46125 3.8168604
    1 1974  96474.38715231481 2068.4353947926643  46.64124  3.842485
    1 1975  94015.23610725581 1984.9228704706516  47.36468  3.857877
    1 1976  91177.75413218774 1982.9200293449796  45.98156 3.8282404
    1 1977  98290.37561635839 2038.0339045082706  48.22804 3.8759406
    1 1978  87961.94122711057 2079.3634866813672  42.30234 3.7448425
    1 1979  96928.38426832571 2029.6833240182743  47.75542  3.866093
    1 1980  93220.74115423675  2078.711716579112  44.84544  3.803222
    1 1981  82051.92622837452 1924.8147751697472  42.62848 3.7525225
    1 1982  79849.12501718079 1781.2045270458907  44.82872  3.802849
    1 1983  85735.08725792539 1895.7092666344713  45.22586  3.811669
    1 1984   88002.3921649081  2104.917812894767  41.80799 3.7330875
    1 1985  79287.94286381664 1939.1580247933905  40.88782  3.710832
    1 1986  88292.65879595853 2090.7399828331645  42.23034  3.743139
    1 1987  89147.33276516253 2100.2994592008563  42.44506 3.7482104
    1 1988   85131.9777022984 2097.5279195786206  40.58681  3.703443
    1 1989  78659.03182987407 2068.8762652915284 38.020172  3.638117
    1 1990  75749.91514979098  2081.923647772041  36.38458  3.594145
    1 1991  83503.25938362662 2105.2072629877307   39.6651  3.680472
    1 1992  93169.13819760557 2140.8637918976674  43.51941  3.773207
    1 1993  97497.33618504625  2041.900975272574  47.74832  3.865944
    1 1994 101884.36142181292 1977.5463018822375   51.5206 3.9419816
    1 1995  94584.76811425512 1732.2202927210528   54.6032 4.0000925
    1 1996 100687.26172185612 1693.1115230135135  59.46877  4.085451
    1 1997 109901.58957180413 1802.9865902154204   60.9553  4.110141
    1 1998 111933.40187743191  1774.277091568325  63.08677  4.144511
    1 1999 103058.35090501276 1674.4346463290058  61.54815 4.1198196
    1 2000  99118.20517743148 1614.1981893122017  61.40399 4.1174746
    1 2001  91821.13534435017 1558.8798759665858    58.902  4.075875
    1 2002  81761.92732222493 1456.1682231979585  56.14868  4.028003
    1 2003  94817.00792603305 1626.6699119328646  58.28903  4.065414
    1 2004 106172.34597537403 1833.8680433666236   57.8953  4.058636
    1 2005 114091.12203451614 1879.9724367204637  60.68766 4.1057405
    1 2006 124249.43895041167 1965.8034071789314  63.20543   4.14639
    1 2007 133692.06538691575 2058.3684560689817   64.9505 4.1736255
    1 2008 139769.61140272173  2080.601922405474  67.17749 4.2073383
    1 2009 139003.53673925626 1979.5619769869206  70.21934 4.2516236
    1 2010  152664.4759775696  2097.052975198907  72.79953 4.2877097
    1 2011 169423.55210595185  2163.602077878524  78.30624  4.360627
    2 1950 1876.5492454289868 117.17786841216812 16.014536  2.773497
    2 1951 1978.8063316717348 117.08795575486364  16.90017  2.827324
    2 1952 1990.3012734507795 115.31912204914569 17.259073  2.848338
    2 1953 1887.8047092543006 121.50604447254129 15.536715  2.743206
    2 1954  2225.229146059998 140.88023102922068 15.795184  2.759705
    2 1955 2358.1394103801977  139.4072409944698 16.915472  2.828229
    2 1956 2172.0650403319178  132.9934547621734 16.332119  2.793134
    2 1957  1535.293161363608  93.03642803680854 16.502066 2.8034856
    2 1958 1679.4588895091222  91.09551002822022 18.436243 2.9143186
    2 1959 1679.4588895091222  89.23672472001341 18.820267 2.9349344
    2 1960 1808.3564115030504  91.72401587925557  19.71519 2.9813895
    2 1961 1812.1475150911072  89.47989175934643  20.25201  3.008254
    2 1962 2005.4937980819993  97.34967877635661  20.60093  3.025336
    2 1963  2126.809112899814  98.38118116547682  21.61805 3.0735285
    2 1964  2316.348577883631  105.7407094118738  21.90593 3.0867574
    2 1965  2530.131462807239 110.92662087394112 22.809055  3.127158
    2 1966  2843.091974757264 120.69012244612864  23.55696  3.159421
    2 1967  2959.901179921709 125.82937529654227 23.523134  3.157984
    2 1968 3034.8353870083347  120.7028296215909 25.143034  3.224581
    2 1969   3270.65774460448 135.63049377714574  24.11447  3.182812
    2 1970 3446.9735259847753 137.75197718945867  25.02304  3.219797
    2 1971  3543.947205743938  141.6690901189019  25.01567 3.2195024
    2 1972 3733.4866707277556 149.18258302647425  25.02629  3.219927
    2 1973  3919.788400803991 154.53407544733676 25.365204 3.2333784
    2 1974  4363.186518385432 169.12793741855776  25.79814 3.2503026
    2 1975  4629.597992394448 176.09729334940593     26.29  3.269189
    2 1976  5015.242573652255   186.547089407307  26.88459  3.291553
    2 1977 5363.6268088948145 195.74580193084586  27.40098  3.310579
    2 1978  5607.682075294683 202.70465239466938   27.6643  3.320143
    2 1979  5764.175528558721 207.74629043878835 27.746225    3.3231
    2 1980  5836.833203288453 212.43402955692028  27.47598  3.313312
    2 1981  5384.473758969947 194.44809862683405  27.69106 3.3211095
    2 1982  4718.761726771142  171.9152240302023  27.44819    3.3123
    2 1983  4727.529641341565 166.88966916399892 28.327276  3.343825
    2 1984  4775.915540267235 167.15019802573653   28.5726  3.352448
    2 1985  4378.436746408045  158.2217371411401  27.67279 3.3204496
    2 1986  4462.543778768772 155.27145926516712  28.74027  3.358299
    2 1987  4574.578242724181 162.16060772421343  28.21017 3.3396826
    end
    label values NAMES_STD1 NAMES_STD1
    label def NAMES_STD1 1 "Argentina", modify
    label def NAMES_STD1 2 "Bolivia", modify

    Comment


    • #3
      Hugo:
      do you mean something along the following lines?
      Code:
      . bysort NAMES_STD1: g ln_1970=ln(val_added_worker) if Year==1970
      . replace ln_1970=0 if ln_1970==.
      . bysort NAMES_STD1: replace ln_1970=sum( ln_1970)
      . bysort NAMES_STD1 Year: gen perc_wanted= lval_added_worker/ln_1970
      . list
      
           +--------------------------------------------------------------------------------------+
           | NAMES_S~1   Year   MANVA_Q05      MANEMP   val_ad~r   lval_a~r    ln_1970   perc_w~d |
           |--------------------------------------------------------------------------------------|
        1. | Argentina   1950   40415.975   1603.2487    25.2088   3.227193     3.6253   .8901864 |
        2. | Argentina   1951   41425.265   1640.9271   25.24504    3.22863     3.6253   .8905826 |
        3. | Argentina   1952   38394.621   1690.1175   22.71713   3.123119     3.6253   .8614787 |
        4. | Argentina   1953   37586.314   1578.1245   23.81708   3.170403     3.6253   .8745214 |
        5. | Argentina   1954   40819.545   1721.9975   23.70477   3.165676     3.6253   .8732176 |
           |--------------------------------------------------------------------------------------|
        6. | Argentina   1955   44536.581   1839.9443    24.2054   3.186576     3.6253   .8789826 |
        7. | Argentina   1956   43852.174   1870.1773   23.44814   3.154791     3.6253   .8702151 |
        8. | Argentina   1957   46044.045   1939.5803   23.73918   3.167127     3.6253   .8736178 |
        9. | Argentina   1958   48480.769    2042.999    23.7302   3.166749     3.6253   .8735134 |
       10. | Argentina   1959   42206.058   1931.8565   21.84741   3.084082     3.6253   .8507109 |
           |--------------------------------------------------------------------------------------|
       11. | Argentina   1960   45347.839   2050.8917   22.11128   3.096088     3.6253   .8540224 |
       12. | Argentina   1961   49732.739    2087.512   23.82393   3.170691     3.6253   .8746008 |
       13. | Argentina   1962   47484.481   1990.2596   23.85844   3.172138     3.6253   .8750001 |
       14. | Argentina   1963   45300.003   1927.1958   23.50566   3.157241     3.6253   .8708909 |
       15. | Argentina   1964   52156.393   2029.1571   25.70348   3.246626     3.6253   .8955469 |
           |--------------------------------------------------------------------------------------|
       16. | Argentina   1965    58789.55   2094.2724   28.07159   3.334758     3.6253    .919857 |
       17. | Argentina   1966    58661.99   2051.6872   28.59207    3.35313     3.6253   .9249246 |
       18. | Argentina   1967   59092.507   1979.7033   29.84917   3.396157     3.6253   .9367933 |
       19. | Argentina   1968   63477.407   2005.6411   31.64944    3.45472     3.6253   .9529473 |
       20. | Argentina   1969   71034.241   2049.4972   34.65935   3.545568     3.6253   .9780065 |
           |--------------------------------------------------------------------------------------|
       21. | Argentina   1970   75568.342   2013.2231     37.536     3.6253     3.6253          1 |
       22. | Argentina   1971   83125.176   2009.7845   41.36024    3.72232     3.6253   1.026762 |
       23. | Argentina   1972   87659.276   2012.0142   43.56792   3.774321     3.6253   1.041106 |
       24. | Argentina   1973   91139.921   2004.7825   45.46125    3.81686     3.6253    1.05284 |
       25. | Argentina   1974   96474.387   2068.4354   46.64124   3.842485     3.6253   1.059908 |
           |--------------------------------------------------------------------------------------|
       26. | Argentina   1975   94015.236   1984.9229   47.36468   3.857877     3.6253   1.064154 |
       27. | Argentina   1976   91177.754     1982.92   45.98156    3.82824     3.6253   1.055979 |
       28. | Argentina   1977   98290.376   2038.0339   48.22804   3.875941     3.6253   1.069136 |
       29. | Argentina   1978   87961.941   2079.3635   42.30234   3.744843     3.6253   1.032974 |
       30. | Argentina   1979   96928.384   2029.6833   47.75542   3.866093     3.6253    1.06642 |
           |--------------------------------------------------------------------------------------|
       31. | Argentina   1980   93220.741   2078.7117   44.84544   3.803222     3.6253   1.049078 |
       32. | Argentina   1981   82051.926   1924.8148   42.62848   3.752522     3.6253   1.035093 |
       33. | Argentina   1982   79849.125   1781.2045   44.82872   3.802849     3.6253   1.048975 |
       34. | Argentina   1983   85735.087   1895.7093   45.22586   3.811669     3.6253   1.051408 |
       35. | Argentina   1984   88002.392   2104.9178   41.80799   3.733088     3.6253   1.029732 |
           |--------------------------------------------------------------------------------------|
       36. | Argentina   1985   79287.943    1939.158   40.88782   3.710832     3.6253   1.023593 |
       37. | Argentina   1986   88292.659     2090.74   42.23034   3.743139     3.6253   1.032505 |
       38. | Argentina   1987   89147.333   2100.2995   42.44506    3.74821     3.6253   1.033903 |
       39. | Argentina   1988   85131.978   2097.5279   40.58681   3.703443     3.6253   1.021555 |
       40. | Argentina   1989   78659.032   2068.8763   38.02017   3.638117     3.6253   1.003535 |
           |--------------------------------------------------------------------------------------|
       41. | Argentina   1990   75749.915   2081.9236   36.38458   3.594145     3.6253   .9914061 |
       42. | Argentina   1991   83503.259   2105.2073    39.6651   3.680472     3.6253   1.015218 |
       43. | Argentina   1992   93169.138   2140.8638   43.51941   3.773207     3.6253   1.040798 |
       44. | Argentina   1993   97497.336    2041.901   47.74832   3.865944     3.6253   1.066379 |
       45. | Argentina   1994   101884.36   1977.5463    51.5206   3.941982     3.6253   1.087353 |
           |--------------------------------------------------------------------------------------|
       46. | Argentina   1995   94584.768   1732.2203    54.6032   4.000093     3.6253   1.103382 |
       47. | Argentina   1996   100687.26   1693.1115   59.46877   4.085451     3.6253   1.126928 |
       48. | Argentina   1997   109901.59   1802.9866    60.9553   4.110141     3.6253   1.133738 |
       49. | Argentina   1998    111933.4   1774.2771   63.08677   4.144511     3.6253   1.143219 |
       50. | Argentina   1999   103058.35   1674.4346   61.54815    4.11982     3.6253   1.136408 |
           |--------------------------------------------------------------------------------------|
       51. | Argentina   2000   99118.205   1614.1982   61.40399   4.117475     3.6253   1.135761 |
       52. | Argentina   2001   91821.135   1558.8799     58.902   4.075875     3.6253   1.124286 |
       53. | Argentina   2002   81761.927   1456.1682   56.14868   4.028003     3.6253   1.111081 |
       54. | Argentina   2003   94817.008   1626.6699   58.28903   4.065414     3.6253   1.121401 |
       55. | Argentina   2004   106172.35    1833.868    57.8953   4.058636     3.6253   1.119531 |
           |--------------------------------------------------------------------------------------|
       56. | Argentina   2005   114091.12   1879.9724   60.68766   4.105741     3.6253   1.132524 |
       57. | Argentina   2006   124249.44   1965.8034   63.20543    4.14639     3.6253   1.143737 |
       58. | Argentina   2007   133692.07   2058.3685    64.9505   4.173625     3.6253    1.15125 |
       59. | Argentina   2008   139769.61   2080.6019   67.17749   4.207338     3.6253   1.160549 |
       60. | Argentina   2009   139003.54    1979.562   70.21934   4.251624     3.6253   1.172765 |
           |--------------------------------------------------------------------------------------|
       61. | Argentina   2010   152664.48    2097.053   72.79953    4.28771     3.6253   1.182719 |
       62. | Argentina   2011   169423.55   2163.6021   78.30624   4.360627     3.6253   1.202832 |
       63. |   Bolivia   1950   1876.5492   117.17787   16.01454   2.773497   3.219797   .8613888 |
       64. |   Bolivia   1951   1978.8063   117.08796   16.90017   2.827324   3.219797   .8781062 |
       65. |   Bolivia   1952   1990.3013   115.31912   17.25907   2.848338   3.219797   .8846327 |
           |--------------------------------------------------------------------------------------|
       66. |   Bolivia   1953   1887.8047   121.50604   15.53671   2.743206   3.219797    .851981 |
       67. |   Bolivia   1954   2225.2291   140.88023   15.79518   2.759705   3.219797   .8571053 |
       68. |   Bolivia   1955   2358.1394   139.40724   16.91547   2.828229   3.219797   .8783873 |
       69. |   Bolivia   1956    2172.065   132.99345   16.33212   2.793134   3.219797   .8674875 |
       70. |   Bolivia   1957   1535.2932   93.036428   16.50207   2.803486   3.219797   .8707026 |
           |--------------------------------------------------------------------------------------|
       71. |   Bolivia   1958   1679.4589    91.09551   18.43624   2.914319   3.219797   .9051249 |
       72. |   Bolivia   1959   1679.4589   89.236725   18.82027   2.934934   3.219797   .9115278 |
       73. |   Bolivia   1960   1808.3564   91.724016   19.71519    2.98139   3.219797   .9259557 |
       74. |   Bolivia   1961   1812.1475   89.479892   20.25201   3.008254   3.219797   .9342992 |
       75. |   Bolivia   1962   2005.4938   97.349679   20.60093   3.025336   3.219797   .9396045 |
           |--------------------------------------------------------------------------------------|
       76. |   Bolivia   1963   2126.8091   98.381181   21.61805   3.073529   3.219797   .9545721 |
       77. |   Bolivia   1964   2316.3486   105.74071   21.90593   3.086757   3.219797   .9586807 |
       78. |   Bolivia   1965   2530.1315   110.92662   22.80906   3.127158   3.219797   .9712282 |
       79. |   Bolivia   1966    2843.092   120.69012   23.55696   3.159421   3.219797   .9812484 |
       80. |   Bolivia   1967   2959.9012   125.82938   23.52313   3.157984   3.219797   .9808022 |
           |--------------------------------------------------------------------------------------|
       81. |   Bolivia   1968   3034.8354   120.70283   25.14303   3.224581   3.219797   1.001486 |
       82. |   Bolivia   1969   3270.6577   135.63049   24.11447   3.182812   3.219797   .9885132 |
       83. |   Bolivia   1970   3446.9735   137.75198   25.02304   3.219797   3.219797   .9999999 |
       84. |   Bolivia   1971   3543.9472   141.66909   25.01567   3.219502   3.219797   .9999084 |
       85. |   Bolivia   1972   3733.4867   149.18258   25.02629   3.219927   3.219797    1.00004 |
           |--------------------------------------------------------------------------------------|
       86. |   Bolivia   1973   3919.7884   154.53408    25.3652   3.233378   3.219797   1.004218 |
       87. |   Bolivia   1974   4363.1865   169.12794   25.79814   3.250303   3.219797   1.009474 |
       88. |   Bolivia   1975    4629.598   176.09729      26.29   3.269189   3.219797    1.01534 |
       89. |   Bolivia   1976   5015.2426   186.54709   26.88459   3.291553   3.219797   1.022286 |
       90. |   Bolivia   1977   5363.6268    195.7458   27.40098   3.310579   3.219797   1.028195 |
           |--------------------------------------------------------------------------------------|
       91. |   Bolivia   1978   5607.6821   202.70465    27.6643   3.320143   3.219797   1.031165 |
       92. |   Bolivia   1979   5764.1755   207.74629   27.74623     3.3231   3.219797   1.032084 |
       93. |   Bolivia   1980   5836.8332   212.43403   27.47598   3.313312   3.219797   1.029044 |
       94. |   Bolivia   1981   5384.4738    194.4481   27.69106    3.32111   3.219797   1.031465 |
       95. |   Bolivia   1982   4718.7617   171.91522   27.44819     3.3123   3.219797   1.028729 |
           |--------------------------------------------------------------------------------------|
       96. |   Bolivia   1983   4727.5296   166.88967   28.32728   3.343825   3.219797    1.03852 |
       97. |   Bolivia   1984   4775.9155    167.1502    28.5726   3.352448   3.219797   1.041198 |
       98. |   Bolivia   1985   4378.4367   158.22174   27.67279    3.32045   3.219797    1.03126 |
       99. |   Bolivia   1986   4462.5438   155.27146   28.74027   3.358299   3.219797   1.043016 |
      100. |   Bolivia   1987   4574.5782   162.16061   28.21017   3.339683   3.219797   1.037234 |
           +--------------------------------------------------------------------------------------+
      
      .
      Kind regards,
      Carlo
      (Stata 18.0 SE)

      Comment


      • #4
        Here is a variation on the theme by Carlo Lazzaro


        Code:
        egen base = mean(cond(Year == 1970, val_added_worker, .)) 
        
        gen wanted = (ln(val_added_worker) - ln(base)) / abs(Year - 1970)
        The need to copy a reference value across a panel is common. See https://www.stata-journal.com/articl...article=dm0055 for discussion of this and related problems.

        Comment


        • #5
          Nick:
          smarter an more efficient than my proposal (2 vs 4 lines).
          Great indeed!
          Kind regards,
          Carlo
          (Stata 18.0 SE)

          Comment


          • #6
            Thank you both for your help ! I will try Professor Cox's syntax. The problem that I am facing right now with my data is that I have an unbalanced panel of more than 100 countries including more than 50 industries within manufacturing. For my initial regressions, what I need to compare the initial value added per worker ( I am using the 70's as a reference, but I may change it due to more technological intensive industries) and the final value added per worker (2018). In that sense, I think your help is tremendous!

            Comment


            • #7
              Rates of change calculated over very short periods are less helpful than one hopes.

              Comment


              • #8
                Yes, that's why I need to think a little deeper. For some industries, I have data from 1960's until 2018. For others, less (think about computers or cellphones, we didn't have those until mid 90's). Now, I am trying to follow a similar approach of your code with more disaggregated data (manufacturing industries, different than the one I asked here), but I think now the issue is more subtle. I am opening a new post soon.

                Thank you so much!


                Comment


                • #9
                  Originally posted by Nick Cox View Post
                  Here is a variation on the theme by Carlo Lazzaro


                  Code:
                  egen base = mean(cond(Year == 1970, val_added_worker, .))
                  
                  gen wanted = (ln(val_added_worker) - ln(base)) / abs(Year - 1970)
                  The need to copy a reference value across a panel is common. See https://www.stata-journal.com/articl...article=dm0055 for discussion of this and related problems.
                  When I apply the in the data, I get what is in the picture. The data that I am trying to work now is more disaggregated, that possibly plays a role.

                  My end goal is to plot:

                  Wanted LogValueAdded per worker_1970 and I am not getting accurate plots.

                  The code that I am applying right now goes as follows:

                  egen base = mean(cond(year == 1970, val_per_worker, .))

                  gen wanted = (ln(val_per_worker) - ln(base)) / abs(year - 1970)



                  Attached Files

                  Comment


                  • #10
                    It’s not explicit in #1 but as Carlo guessed in #2 you presumably want calculations to be separate for each country, in which case you should use by NAMES: as a prefix. Sorry about that.

                    Comment


                    • #11
                      Thank you! I think I've also need to separate by industry. I am trying
                      by country isic: egen base = mean(cond(year == 1970, val_per_worker, .))
                      gen wanted = (ln(val_per_worker) - ln(base)) / abs(year - 1970)

                      Comment


                      • #12
                        Using aaplot (but doing the work manually by exporting excel files I get this). I guess, I should get something equivalent

                        Attached Files

                        Comment


                        • #13
                          Originally posted by Carlo Lazzaro View Post
                          Hugo:
                          do you mean something along the following lines?
                          Code:
                          . bysort NAMES_STD1: g ln_1970=ln(val_added_worker) if Year==1970
                          . replace ln_1970=0 if ln_1970==.
                          . bysort NAMES_STD1: replace ln_1970=sum( ln_1970)
                          . bysort NAMES_STD1 Year: gen perc_wanted= lval_added_worker/ln_1970
                          . list
                          
                          +--------------------------------------------------------------------------------------+
                          | NAMES_S~1 Year MANVA_Q05 MANEMP val_ad~r lval_a~r ln_1970 perc_w~d |
                          |--------------------------------------------------------------------------------------|
                          1. | Argentina 1950 40415.975 1603.2487 25.2088 3.227193 3.6253 .8901864 |
                          2. | Argentina 1951 41425.265 1640.9271 25.24504 3.22863 3.6253 .8905826 |
                          3. | Argentina 1952 38394.621 1690.1175 22.71713 3.123119 3.6253 .8614787 |
                          4. | Argentina 1953 37586.314 1578.1245 23.81708 3.170403 3.6253 .8745214 |
                          5. | Argentina 1954 40819.545 1721.9975 23.70477 3.165676 3.6253 .8732176 |
                          |--------------------------------------------------------------------------------------|
                          6. | Argentina 1955 44536.581 1839.9443 24.2054 3.186576 3.6253 .8789826 |
                          7. | Argentina 1956 43852.174 1870.1773 23.44814 3.154791 3.6253 .8702151 |
                          8. | Argentina 1957 46044.045 1939.5803 23.73918 3.167127 3.6253 .8736178 |
                          9. | Argentina 1958 48480.769 2042.999 23.7302 3.166749 3.6253 .8735134 |
                          10. | Argentina 1959 42206.058 1931.8565 21.84741 3.084082 3.6253 .8507109 |
                          |--------------------------------------------------------------------------------------|
                          11. | Argentina 1960 45347.839 2050.8917 22.11128 3.096088 3.6253 .8540224 |
                          12. | Argentina 1961 49732.739 2087.512 23.82393 3.170691 3.6253 .8746008 |
                          13. | Argentina 1962 47484.481 1990.2596 23.85844 3.172138 3.6253 .8750001 |
                          14. | Argentina 1963 45300.003 1927.1958 23.50566 3.157241 3.6253 .8708909 |
                          15. | Argentina 1964 52156.393 2029.1571 25.70348 3.246626 3.6253 .8955469 |
                          |--------------------------------------------------------------------------------------|
                          16. | Argentina 1965 58789.55 2094.2724 28.07159 3.334758 3.6253 .919857 |
                          17. | Argentina 1966 58661.99 2051.6872 28.59207 3.35313 3.6253 .9249246 |
                          18. | Argentina 1967 59092.507 1979.7033 29.84917 3.396157 3.6253 .9367933 |
                          19. | Argentina 1968 63477.407 2005.6411 31.64944 3.45472 3.6253 .9529473 |
                          20. | Argentina 1969 71034.241 2049.4972 34.65935 3.545568 3.6253 .9780065 |
                          |--------------------------------------------------------------------------------------|
                          21. | Argentina 1970 75568.342 2013.2231 37.536 3.6253 3.6253 1 |
                          22. | Argentina 1971 83125.176 2009.7845 41.36024 3.72232 3.6253 1.026762 |
                          23. | Argentina 1972 87659.276 2012.0142 43.56792 3.774321 3.6253 1.041106 |
                          24. | Argentina 1973 91139.921 2004.7825 45.46125 3.81686 3.6253 1.05284 |
                          25. | Argentina 1974 96474.387 2068.4354 46.64124 3.842485 3.6253 1.059908 |
                          |--------------------------------------------------------------------------------------|
                          26. | Argentina 1975 94015.236 1984.9229 47.36468 3.857877 3.6253 1.064154 |
                          27. | Argentina 1976 91177.754 1982.92 45.98156 3.82824 3.6253 1.055979 |
                          28. | Argentina 1977 98290.376 2038.0339 48.22804 3.875941 3.6253 1.069136 |
                          29. | Argentina 1978 87961.941 2079.3635 42.30234 3.744843 3.6253 1.032974 |
                          30. | Argentina 1979 96928.384 2029.6833 47.75542 3.866093 3.6253 1.06642 |
                          |--------------------------------------------------------------------------------------|
                          31. | Argentina 1980 93220.741 2078.7117 44.84544 3.803222 3.6253 1.049078 |
                          32. | Argentina 1981 82051.926 1924.8148 42.62848 3.752522 3.6253 1.035093 |
                          33. | Argentina 1982 79849.125 1781.2045 44.82872 3.802849 3.6253 1.048975 |
                          34. | Argentina 1983 85735.087 1895.7093 45.22586 3.811669 3.6253 1.051408 |
                          35. | Argentina 1984 88002.392 2104.9178 41.80799 3.733088 3.6253 1.029732 |
                          |--------------------------------------------------------------------------------------|
                          36. | Argentina 1985 79287.943 1939.158 40.88782 3.710832 3.6253 1.023593 |
                          37. | Argentina 1986 88292.659 2090.74 42.23034 3.743139 3.6253 1.032505 |
                          38. | Argentina 1987 89147.333 2100.2995 42.44506 3.74821 3.6253 1.033903 |
                          39. | Argentina 1988 85131.978 2097.5279 40.58681 3.703443 3.6253 1.021555 |
                          40. | Argentina 1989 78659.032 2068.8763 38.02017 3.638117 3.6253 1.003535 |
                          |--------------------------------------------------------------------------------------|
                          41. | Argentina 1990 75749.915 2081.9236 36.38458 3.594145 3.6253 .9914061 |
                          42. | Argentina 1991 83503.259 2105.2073 39.6651 3.680472 3.6253 1.015218 |
                          43. | Argentina 1992 93169.138 2140.8638 43.51941 3.773207 3.6253 1.040798 |
                          44. | Argentina 1993 97497.336 2041.901 47.74832 3.865944 3.6253 1.066379 |
                          45. | Argentina 1994 101884.36 1977.5463 51.5206 3.941982 3.6253 1.087353 |
                          |--------------------------------------------------------------------------------------|
                          46. | Argentina 1995 94584.768 1732.2203 54.6032 4.000093 3.6253 1.103382 |
                          47. | Argentina 1996 100687.26 1693.1115 59.46877 4.085451 3.6253 1.126928 |
                          48. | Argentina 1997 109901.59 1802.9866 60.9553 4.110141 3.6253 1.133738 |
                          49. | Argentina 1998 111933.4 1774.2771 63.08677 4.144511 3.6253 1.143219 |
                          50. | Argentina 1999 103058.35 1674.4346 61.54815 4.11982 3.6253 1.136408 |
                          |--------------------------------------------------------------------------------------|
                          51. | Argentina 2000 99118.205 1614.1982 61.40399 4.117475 3.6253 1.135761 |
                          52. | Argentina 2001 91821.135 1558.8799 58.902 4.075875 3.6253 1.124286 |
                          53. | Argentina 2002 81761.927 1456.1682 56.14868 4.028003 3.6253 1.111081 |
                          54. | Argentina 2003 94817.008 1626.6699 58.28903 4.065414 3.6253 1.121401 |
                          55. | Argentina 2004 106172.35 1833.868 57.8953 4.058636 3.6253 1.119531 |
                          |--------------------------------------------------------------------------------------|
                          56. | Argentina 2005 114091.12 1879.9724 60.68766 4.105741 3.6253 1.132524 |
                          57. | Argentina 2006 124249.44 1965.8034 63.20543 4.14639 3.6253 1.143737 |
                          58. | Argentina 2007 133692.07 2058.3685 64.9505 4.173625 3.6253 1.15125 |
                          59. | Argentina 2008 139769.61 2080.6019 67.17749 4.207338 3.6253 1.160549 |
                          60. | Argentina 2009 139003.54 1979.562 70.21934 4.251624 3.6253 1.172765 |
                          |--------------------------------------------------------------------------------------|
                          61. | Argentina 2010 152664.48 2097.053 72.79953 4.28771 3.6253 1.182719 |
                          62. | Argentina 2011 169423.55 2163.6021 78.30624 4.360627 3.6253 1.202832 |
                          63. | Bolivia 1950 1876.5492 117.17787 16.01454 2.773497 3.219797 .8613888 |
                          64. | Bolivia 1951 1978.8063 117.08796 16.90017 2.827324 3.219797 .8781062 |
                          65. | Bolivia 1952 1990.3013 115.31912 17.25907 2.848338 3.219797 .8846327 |
                          |--------------------------------------------------------------------------------------|
                          66. | Bolivia 1953 1887.8047 121.50604 15.53671 2.743206 3.219797 .851981 |
                          67. | Bolivia 1954 2225.2291 140.88023 15.79518 2.759705 3.219797 .8571053 |
                          68. | Bolivia 1955 2358.1394 139.40724 16.91547 2.828229 3.219797 .8783873 |
                          69. | Bolivia 1956 2172.065 132.99345 16.33212 2.793134 3.219797 .8674875 |
                          70. | Bolivia 1957 1535.2932 93.036428 16.50207 2.803486 3.219797 .8707026 |
                          |--------------------------------------------------------------------------------------|
                          71. | Bolivia 1958 1679.4589 91.09551 18.43624 2.914319 3.219797 .9051249 |
                          72. | Bolivia 1959 1679.4589 89.236725 18.82027 2.934934 3.219797 .9115278 |
                          73. | Bolivia 1960 1808.3564 91.724016 19.71519 2.98139 3.219797 .9259557 |
                          74. | Bolivia 1961 1812.1475 89.479892 20.25201 3.008254 3.219797 .9342992 |
                          75. | Bolivia 1962 2005.4938 97.349679 20.60093 3.025336 3.219797 .9396045 |
                          |--------------------------------------------------------------------------------------|
                          76. | Bolivia 1963 2126.8091 98.381181 21.61805 3.073529 3.219797 .9545721 |
                          77. | Bolivia 1964 2316.3486 105.74071 21.90593 3.086757 3.219797 .9586807 |
                          78. | Bolivia 1965 2530.1315 110.92662 22.80906 3.127158 3.219797 .9712282 |
                          79. | Bolivia 1966 2843.092 120.69012 23.55696 3.159421 3.219797 .9812484 |
                          80. | Bolivia 1967 2959.9012 125.82938 23.52313 3.157984 3.219797 .9808022 |
                          |--------------------------------------------------------------------------------------|
                          81. | Bolivia 1968 3034.8354 120.70283 25.14303 3.224581 3.219797 1.001486 |
                          82. | Bolivia 1969 3270.6577 135.63049 24.11447 3.182812 3.219797 .9885132 |
                          83. | Bolivia 1970 3446.9735 137.75198 25.02304 3.219797 3.219797 .9999999 |
                          84. | Bolivia 1971 3543.9472 141.66909 25.01567 3.219502 3.219797 .9999084 |
                          85. | Bolivia 1972 3733.4867 149.18258 25.02629 3.219927 3.219797 1.00004 |
                          |--------------------------------------------------------------------------------------|
                          86. | Bolivia 1973 3919.7884 154.53408 25.3652 3.233378 3.219797 1.004218 |
                          87. | Bolivia 1974 4363.1865 169.12794 25.79814 3.250303 3.219797 1.009474 |
                          88. | Bolivia 1975 4629.598 176.09729 26.29 3.269189 3.219797 1.01534 |
                          89. | Bolivia 1976 5015.2426 186.54709 26.88459 3.291553 3.219797 1.022286 |
                          90. | Bolivia 1977 5363.6268 195.7458 27.40098 3.310579 3.219797 1.028195 |
                          |--------------------------------------------------------------------------------------|
                          91. | Bolivia 1978 5607.6821 202.70465 27.6643 3.320143 3.219797 1.031165 |
                          92. | Bolivia 1979 5764.1755 207.74629 27.74623 3.3231 3.219797 1.032084 |
                          93. | Bolivia 1980 5836.8332 212.43403 27.47598 3.313312 3.219797 1.029044 |
                          94. | Bolivia 1981 5384.4738 194.4481 27.69106 3.32111 3.219797 1.031465 |
                          95. | Bolivia 1982 4718.7617 171.91522 27.44819 3.3123 3.219797 1.028729 |
                          |--------------------------------------------------------------------------------------|
                          96. | Bolivia 1983 4727.5296 166.88967 28.32728 3.343825 3.219797 1.03852 |
                          97. | Bolivia 1984 4775.9155 167.1502 28.5726 3.352448 3.219797 1.041198 |
                          98. | Bolivia 1985 4378.4367 158.22174 27.67279 3.32045 3.219797 1.03126 |
                          99. | Bolivia 1986 4462.5438 155.27146 28.74027 3.358299 3.219797 1.043016 |
                          100. | Bolivia 1987 4574.5782 162.16061 28.21017 3.339683 3.219797 1.037234 |
                          +--------------------------------------------------------------------------------------+
                          
                          .
                          Hi! I am very very sorry to bother again but I am really struggling to apply the syntax (the panel is unbalanced in this case which makes things more complicated)
                          In your second line:

                          bysort NAMES_STD1: replace ln_1970=sum( ln_1970)

                          We clearly sum the logs of industries in the 1970's, when I want to do aaplot ( percent_wanted logvalueadded_1970) what I get is obviously the sum of logs by countries (add up industries) and not the log of initial value added in the 1970's

                          Comment


                          • #14
                            Hugo:
                            I fail to get what the problem is.
                            Do you mean that you have to include both -NAMES_STD1- and -industry- as -bysort pefix?
                            Kind regards,
                            Carlo
                            (Stata 18.0 SE)

                            Comment


                            • #15
                              Hi Professor Lazaro!

                              I am trying to replicate your code with a different dataset that I am using (it is an unbalanced panel with more countries and instead of aggreagate manufacturing I have more industries).

                              The problem I am running now is that I am trying to do aaplots (aaplot perc_wanted ln_1970) with x-axis being log_value_added_perworker in 1970. Since in the second line, your code says

                              bysort NAMES_STD1: replace ln_1970=sum( ln_1970) I am getting the sum of ln_1970 by country and not the initial values of 1970 per industry (isic). I wrote a new post with this new data but I was told to come back here

                              Thank you so much for your help!

                              Comment

                              Working...
                              X