Announcement

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

  • dataset from IMF

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str7 Country str10 Subject double(C D E F G H I J K L M N O P Q R S T U V)
    "Canada"  "GDPP"       24296.458 23859.505 24279.044 28338.565 32176.401 36439.158  40558.03 44717.014 46773.865 40990.625 47627.317 52285.937 52744.033  52708.61  51020.69 43626.426  42439.65 45217.026  46290.217 46212.842
    "Canada"  "BS"         29884.284 30760.908 31843.481 32711.044  34305.36 36163.548 37857.215 39294.255 40034.725  38713.59 39926.148  41625.95  42715.71 44009.215 45642.564 46064.134 46568.617 48273.073  49690.168 50725.441
    "Canada"  "investment"    20.615    19.671    19.739    20.467    21.383    22.632    23.596    23.908    24.072    21.959    23.482    24.151    24.868    24.908    24.869    23.848    22.879    23.546     23.034     22.58
    "Canada"  "CPI"           95.383    97.775       100   102.742   104.633   106.967   109.125    111.45   114.108    114.45   116.475   119.842   121.675     122.8   125.158   126.558   128.375   130.433    133.358   136.043
    "Canada"  "M"              8.486    -4.915     1.823     4.313     8.474     7.311     5.302     5.748      .859    -12.44    13.767     5.573     3.697     1.986     2.454      .603     -.003     4.213      2.886      .742
    "Canada"  "EX"             9.046    -2.969      1.19    -1.727     5.532      2.22      .868     1.143    -4.544   -12.967     6.639     4.766     2.766     2.386     6.232     3.368     1.325     1.117       3.21     3.053
    "Canada"  "Gov"          448.596   470.432   482.179   505.358   522.734   547.605   578.599     607.7   642.524   682.285   717.466   737.571   747.804   760.152   765.452   796.543   822.452   861.958    902.167   935.027
    "Canada"  "RGov"          40.558    41.103    40.394    40.276    39.135    38.521    38.662    38.519    38.775    43.421    43.064    41.575    40.926    39.961    38.371    40.018     40.55     40.25     40.655    40.697
    "Canada"  "CA"            18.584    15.687    12.509     10.19    23.224    21.605    17.968    11.109     1.529   -40.464   -58.246   -49.614   -65.722   -59.333   -43.249   -55.159   -48.945   -46.327    -45.162   -32.477
    "France"  "GDPP"        23212.45 23245.258 25137.402 30682.636 35016.219 36057.117 37795.916 43060.031 47155.211 43190.972 42178.577 45419.973 42372.071 44144.617 44616.455 37937.861 38348.507 40108.915  42953.266 41760.606
    "France"  "BS"         28470.277  29467.38 30060.799 30657.417 32157.706  33457.66  35063.47 36642.442 37245.646 36258.206 37217.313 38640.044 39314.009 40030.973 40949.486 41658.753  42440.34 44114.517  45893.046 47222.641
    "France"  "investment"    22.488    22.165    21.316    21.186     21.89    22.453    23.238    24.165     24.13    21.333    21.946    23.221    22.627    22.287     22.71    22.712    22.609    23.366     23.455    23.314
    "France"  "CPI"           78.226    79.622    81.164    82.927    84.863    86.466    88.102    89.516    92.346    92.441    94.047    96.198    98.329    99.301     99.91    99.998   100.304   101.471    103.603   104.812
    "France"  "M"             15.353     2.382     1.946      .894     6.204      6.32     5.601     5.756     1.295    -9.355     8.893     5.837        .2     2.418     4.899     5.898     2.929     3.949      1.209     2.352
    "France"  "EX"            12.886     3.072     1.997     -.959     5.358     3.976     5.998     2.791      .441   -10.898     8.695     6.364     2.842     2.141     3.272     4.646     1.776     3.857      3.468     2.332
    "France"  "Gov"          763.723   795.531   838.298   868.664   902.872   941.123   977.223  1020.486  1061.865  1106.701  1134.956   1158.67  1192.859  1211.621  1229.958  1248.656  1264.297  1293.953   1318.643  1341.386
    "France"  "RGov"          51.652    51.718    52.795    53.271    52.985    53.294    52.876    52.566    53.296    57.152    56.882    56.291    57.107    57.228    57.214    56.798     56.59     56.38     56.039     55.65
    "France"  "CA"            35.023    39.855     30.95    27.976    24.321     9.698     9.852     1.808   -20.409   -14.854   -16.653   -24.624   -25.901   -14.343   -27.317    -8.978   -11.503   -18.707     -16.16   -13.741
    "Germany" "GDPP"       23924.729 23869.773 25460.334 30668.849 34534.602 35020.197 36894.468 42299.862 46367.859 42338.713 42379.578 46697.376 43883.257 46299.084 48035.802 41159.938 42115.596 44333.806  47662.493 46563.989
    "Germany" "BS"          29861.13 31008.396 31412.122 31780.513 33060.641 34389.168 36855.463 39058.689  40316.43 38444.124 40619.674 43095.965 44027.556 44870.277 46520.051 47411.034 48576.506 50522.374   52385.74 53566.926
    "Germany" "investment"    24.487     22.96    20.776    20.437    19.839    19.485    20.571     21.38    21.446    18.556    20.066    21.635    19.716    20.054     20.37    19.999    20.214    20.747     21.799    21.807
    "Germany" "CPI"           78.942    80.442    81.492    82.383    83.825    85.442    86.967    88.958      91.4    91.625     92.65     94.95    96.992    98.542      99.3    99.975    100.35   102.067    104.033   105.579
    "Germany" "M"             11.277     1.155    -2.564     5.597      6.91     6.221    11.519     6.489     1.849    -9.718    12.631     7.458      .537     2.793     3.878     5.374     4.237     5.666      3.751     2.528
    "Germany" "EX"            14.474     6.068     4.244     1.785    10.406         7    12.829     9.239     1.286   -14.275    14.047     8.511     3.568      1.18     4.685     4.892     2.228     5.536      2.311      .854
    "Germany" "Gov"         1007.254  1030.137  1052.274  1068.281  1058.667  1071.405  1078.898  1084.748  1125.536   1178.85  1234.544  1218.524  1233.138  1263.544   1296.94  1334.518  1388.482  1441.419   1490.498  1556.133
    "Germany" "RGov"          47.758    47.416    47.872    48.304    46.791    46.821    45.235    43.398      44.2      48.2    48.142    45.238    44.918    44.944    44.303    44.042    44.302     44.42     44.567    45.237
    "Germany" "CA"           -34.324    -7.161    39.267     35.36   127.156   133.119   172.872   235.055   213.169   198.881   195.436   232.889   251.608   244.741   280.033   288.413   293.789   295.752    289.507    269.14
    "Italy"   "GDPP"       20116.608 20423.421 22310.073 27495.043 31250.425 31936.387 33341.607 37685.466 40658.138 36862.393 35655.106 38011.624  34470.42 35219.329 35456.715 30153.431 30823.988 32195.433  34320.754 32946.524
    "Italy"   "BS"         28714.275 29844.564 30371.726 30873.515 31968.808 33025.561 34557.939 35871.713 35882.311 33935.377 34758.947 35544.006 35078.132 34878.351 35404.829 36096.273 36957.188 38335.421  39675.525 40470.301
    "Italy"   "investment"    20.718     20.67    21.417    21.065    21.171    21.103    21.894    22.185    21.781    19.393    20.538    20.462    17.862    16.955    17.033    17.303    17.579     17.62     17.953    17.565
    "Italy"   "CPI"           74.217    75.942    77.925    80.117    81.925    83.733      85.6    87.333    90.383    91.075     92.55    95.267    98.425     99.65    99.883    99.992    99.942   101.267    102.525   103.283
    "Italy"   "M"             10.257     2.125      .732     1.463     4.669     3.032     7.799     5.373    -3.651   -12.884    12.393      .526    -8.055    -2.362     3.238     6.805     3.596     5.466      2.316       .77
    "Italy"   "EX"            11.925     2.675    -2.794      -1.3     6.162     3.377     8.227     6.176    -3.092   -18.051    11.785     5.186     2.324      .701     2.719     4.352     2.134     5.907       1.91     1.601
    "Italy"   "Gov"          577.656    617.21   629.649   657.039   678.387   702.315   737.532   753.127   780.664   804.661   800.494   808.562   819.337   819.381   825.502   830.412   828.676   844.895    853.618   863.715
    "Italy"   "RGov"          46.613    47.518    46.786    47.245    46.838    47.144     47.63    46.791     47.83    51.158     49.89    49.379    50.788    51.065      50.9    50.264    49.039    48.912     48.584    48.778
    "Italy"   "CA"              .646     6.105    -3.431    -9.577    -6.245   -16.696   -29.216   -30.656   -67.642   -41.403   -72.631   -68.278    -7.014    21.047    41.141    24.633    47.496    50.664     52.035    57.041
    "Japan"   "GDPP"       38535.586 33850.883 32300.666 34831.196 37696.723  37223.77 35463.873 35342.476 39453.494 41014.185 44673.608 48168.804 48632.903 40490.155  38156.33 34568.925 38804.858 38342.735  39303.958 40846.777
    "Japan"   "BS"         26955.999 27593.641 28004.232 28907.063 30316.005 31775.624  33203.64 34656.625 34962.136 33357.589 35148.788 35775.296 37087.615 38559.409 39486.291 40430.458 41103.549 42760.538   44246.37 45546.185
    "Japan"   "investment"    27.307     26.56    24.656    24.397    24.349    24.749    24.749    24.483    24.548    21.324    21.298    22.103    22.654    23.191    23.916    24.023    23.407    23.904     24.425    24.592
    "Japan"   "CPI"           99.093     98.36    97.451    97.199    97.189    96.914    97.158    97.219    98.565    97.234    96.533     96.27    96.216    96.546    99.212    99.998    99.884   100.352    101.334   102.332
    "Japan"   "M"              9.267     1.029      .687     3.397     8.121       6.1     4.707     2.185      .697    -15.65    11.173     5.804      5.41     3.274     8.268      .751     -1.62     3.379      3.295     -.848
    "Japan"   "EX"            12.741    -6.708     7.765     9.516    14.274     7.169    10.315     8.672     1.558   -23.427    24.911     -.246     -.088      .761      9.29     2.941     1.713      6.83      3.395    -1.649
    "Japan"   "Gov"         192532.9  188455.7  187996.4  186232.4  181108.6  181340.5  179543.3  180817.5  182060.2  193408.4  192882.3    193705    194882  198683.9  199841.5  202016.6  203389.3  203963.8 203512.767 206164.44
    "Japan"   "RGov"          36.554    36.033    36.434    36.134    34.764    34.598    34.077    34.008    34.963    39.511    38.549    39.418    39.374    39.486    38.889    38.022    37.947    37.417      37.07    36.966
    "Japan"   "CA"           130.651    86.186   109.125   139.414   182.049   170.135   174.536   212.138   142.599    145.25   220.986   129.834    59.703    45.944    36.794   136.437   197.923   201.961     175.26   172.113
    "UK"      "GDPP"       28043.874 27510.331 29912.986 34302.415 40111.752 41842.698 44403.814 50315.557  47469.38 38601.319 39122.192 41649.659 42023.101 42981.253 47003.879 44494.861 40657.859 39976.784  42579.817 41030.232
    "UK"      "BS"         26681.919 27934.007 28961.318 30345.707 31727.771 33487.503 35139.277 36704.891 36984.748  35433.71 36170.119 37221.673 38230.852 39449.305 41049.316 42116.547 42959.079 44301.434  45740.756 46826.969
    "UK"      "investment"    18.627    18.146    17.954    17.557    17.296    17.423    17.743    18.372     17.18     14.49    15.795    15.694    15.872    16.244    17.259    17.221    17.263    17.218     17.191    16.423
    "UK"      "CPI"           72.685    73.582    74.508    75.523    76.538    78.112    79.931    81.788    84.733    86.568    89.423    93.415    96.057    98.521     99.96       100    100.66   103.361    105.922   107.836
    "UK"      "M"              9.835     4.787     5.662     3.115      6.76     7.179     9.803    -2.345    -1.849    -8.559     8.135      .735     2.951     3.155     3.793     5.495     3.291     3.511        .66      .379
    "UK"      "EX"             8.533     1.948     2.265     3.033     5.402     7.932    12.095    -1.018       .42    -8.322     5.658     6.443     1.381     1.511     2.282     4.439      1.04     5.612       .116      .425
    "UK"      "Gov"          368.171   391.121   420.599   460.585   494.931   529.889   556.209   585.403   639.551   677.576   705.916   710.613   733.103   730.008   747.681   752.103   765.283   787.202    810.524   838.263
    "UK"      "RGov"          33.798     34.63    35.555    36.792    37.699    38.156    37.943    37.978    40.483    44.078    44.468     43.21    43.266    41.446     40.54    39.671    38.856    38.407     38.273    38.362
    "UK"      "CA"           -39.908   -36.539   -40.248   -39.442    -55.51   -51.485   -82.373  -110.603  -124.095    -85.41   -82.933   -51.618  -100.867  -141.874  -149.646  -142.367  -139.301   -88.059   -109.059    -94.72
    "US"      "GDPP"       36317.741 37101.103  37971.28 39411.546 41629.858  44025.56 46213.508  47869.24 48283.413 47007.674 48402.581 49825.501 51556.171 53061.235 55010.066 56787.457 57901.072 59999.508  62868.917 65111.596
    "US"      "BS"         36317.741 37101.103  37971.28 39411.546 41629.858  44025.56 46213.508  47869.24 48283.413 47007.674 48402.581 49825.501 51556.171 53061.235 55010.066 56787.457 57901.072 59999.508  62868.917 65111.596
    "US"      "investment"    23.675    22.177    21.708    21.742    22.659    23.381    23.539    22.592    21.119    17.805    18.743    19.104    20.021    20.414    20.806    21.093    20.379    20.623     20.969    21.103
    "US"      "CPI"          172.192   177.042   179.867       184   188.908   195.267   201.558   207.344   215.254   214.565   218.076   224.923   229.586   232.952   236.715   236.998   240.008   245.134    251.104   255.668
    "US"      "M"             12.885    -2.803     3.636     4.917    11.399      6.53     6.631     2.498    -2.227   -13.083    13.128     5.635     2.706     1.544     4.997     5.288     1.992     4.707      4.367      2.14
    "US"      "EX"             8.343    -5.783    -1.739     2.185     9.666     7.129     9.342     8.703     5.659    -8.397    12.137      7.14     3.407     3.577     4.213      .472     -.014     3.478      3.016      .326
    "US"      "Gov"                .  3470.858  3683.339  3899.592  4119.149  4423.473  4654.166  5001.963  5485.767  5993.627   5983.28  6045.286  6032.289  6037.155  6216.418  6406.209  6635.975   6880.17   7231.929  7759.305
    "US"      "RGov"               .      32.8    33.679    34.033    33.726    33.931     33.69    34.611    37.286    41.481     39.91    38.895    37.243    35.968    35.467    35.151    35.458    35.248      35.14    36.192
    "US"      "CA"          -403.451  -389.686  -450.794  -518.751  -631.593  -745.233  -805.963  -711.036   -681.39  -372.522  -431.266  -445.663  -426.833  -348.801  -365.199  -407.764  -428.349  -439.646   -490.978  -539.454
    end
    ------------------ copy up to and including the previous line ------------------

    Listed 63 out of 63 observations
    ************************************************** ************
    Can anyone help me, I want to set my panel data set, this is the first time I'm dealing with a dataset from the IMF,
    I cleaned the excel sheet manually, however, the year variable appears like alphabetical variables [C D E F G H I J K L M N O P Q R S T U V] instead of [2000-2019]
    how to declare this data set to be a panel after fixing my year variable

  • #2
    Code:
    ds Country Subject, not
    rename (`r(varlist)') value#, addnumber(2000)
    reshape long value, i(Country Subject) j(year)
    reshape wide value, i(Country year) j(Subject) string
    rename value* *
    encode Country, gen(country_num)
    xtset country_num year
    This does what you want with the data example above. However, it requires quite some rearranging. Also, manually cleaning it in excel doesn't sound so good in case you need to reproduce results.

    I would first try to download the data from the source in another format if possible. Otherwise I would import the downloaded file directly into Stata, do the cleaning there and save all the code in a do-file. It may be that the problem with the years is already solved if you do this.

    Comment

    Working...
    X