Hi everyone,
I have the the HS02 BACI dataset from CEPII. It is bilateral trade data at the product level from 2002 to 2020. Each year is in a separate excel file containing i(exporting country), j(importing country), k(product), v(value), q(quantity). The exporting and importing countries are written as IDs instead of country names. I would like to know the main trading partner j for each exporting country i. After that, I want to put all years in one file where each exporting country i has one main trading partner j per year. How can I do that on Stata?
I have the the HS02 BACI dataset from CEPII. It is bilateral trade data at the product level from 2002 to 2020. Each year is in a separate excel file containing i(exporting country), j(importing country), k(product), v(value), q(quantity). The exporting and importing countries are written as IDs instead of country names. I would like to know the main trading partner j for each exporting country i. After that, I want to put all years in one file where each exporting country i has one main trading partner j per year. How can I do that on Stata?
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int(t i j) long k float v str13 q 2002 4 12 20230 2270.583 " 872.973" 2002 4 12 80232 4.732 " 6.560" 2002 4 12 121110 .547 " 3.706" 2002 4 12 121190 2.87 " 9.400" 2002 4 12 130212 1.155 " 3.910" 2002 4 12 382200 .089 " 0.001" 2002 4 12 540769 15.181 " 10.200" 2002 4 20 570110 10.83 " 0.573" 2002 4 20 570210 1.39 " 0.075" 2002 4 20 701399 .284 " 0.049" 2002 4 36 570110 9.989 " 0.920" 2002 4 36 570190 1.743 " 0.100" 2002 4 36 570210 13.166 " 0.287" 2002 4 36 570231 .191 " 0.017" 2002 4 36 570241 3.064 " 0.577" 2002 4 36 710399 .526 " 0.002" 2002 4 36 871130 73.449 " 6.105" 2002 4 36 970500 .194 " 0.010" 2002 4 40 180690 1.316 " 0.300" 2002 4 40 220410 4.649 " 0.400" 2002 4 40 220421 .694 " 0.100" 2002 4 40 220820 2.162 " 0.593" 2002 4 40 220830 2.521 " 0.360" 2002 4 40 220850 .051 " 0.023" 2002 4 40 220860 2.063 " 0.500" 2002 4 40 220870 .704 " 0.200" 2002 4 40 220890 .508 " 0.256" 2002 4 40 240210 .136 " 0.001" 2002 4 40 240310 .048 " 0.006" 2002 4 40 330499 .442 " 0.049" 2002 4 40 391740 10.384 " 0.100" 2002 4 40 392321 .013 " 0.200" 2002 4 40 392640 .009 " 0.002" 2002 4 40 400829 .811 " 0.158" 2002 4 40 401034 15.706 " 1.100" 2002 4 40 401699 2.618 " 0.100" 2002 4 40 420231 .369 " 0.011" 2002 4 40 441520 .042 " 0.209" 2002 4 40 442190 .32 " 0.264" 2002 4 40 481840 .025 " 0.010" 2002 4 40 481910 .296 " 0.800" 2002 4 40 490199 .24 " 0.026" 2002 4 40 560110 .015 " 0.003" 2002 4 40 570110 48.118 " 2.700" 2002 4 40 570210 17.094 " 1.800" 2002 4 40 611020 .155 " 0.006" 2002 4 40 620342 .09 " 0.004" 2002 4 40 630260 .12 " 0.015" 2002 4 40 630499 5.586 " 0.700" 2002 4 40 650590 .428 " 0.100" 2002 4 40 691200 1.01 " 0.300" 2002 4 40 701310 1.743 " 0.800" 2002 4 40 720449 .388 " 0.500" 2002 4 40 820890 .015 " 0.001" 2002 4 40 852290 .389 " 0.016" 2002 4 40 853610 .008 " NA" 2002 4 40 853630 16.017 " 0.100" 2002 4 40 853931 3.059 " 0.500" 2002 4 40 854221 .04 " NA" 2002 4 40 854459 2.598 " 0.300" 2002 4 40 910211 .382 " 0.003" 2002 4 40 950341 3.239 " 0.200" 2002 4 40 960500 .038 " 0.002" 2002 4 40 970600 .863 " 0.004" 2002 4 48 80232 .449 " 0.130" 2002 4 48 80620 .09 " 0.100" 2002 4 48 121299 5.502 " 4.200" 2002 4 48 262040 24.636 " 102.000" 2002 4 48 520419 .117 " 0.010" 2002 4 48 570110 39.359 " 4.070" 2002 4 48 610432 .069 " 0.005" 2002 4 48 610821 2.543 " 0.025" 2002 4 48 620342 .979 " 0.120" 2002 4 48 620520 .112 " 0.010" 2002 4 50 90930 2704.045 " 3112.279" 2002 4 50 520100 428.32 " 433.433" 2002 4 50 521225 .013 " 0.001" 2002 4 50 701399 1.885 " 2.200" 2002 4 50 847030 1.44 " NA" 2002 4 50 851631 1.44 " 0.106" 2002 4 50 902720 29.077 " 0.115" 2002 4 50 940540 1.44 " 0.636" 2002 4 56 420239 3.792 " 0.118" 2002 4 56 510211 3298.092 " 262.170" 2002 4 56 510219 1360.035 " 92.070" 2002 4 56 620111 16.911 " 0.472" 2002 4 56 620461 5.83 " 0.122" 2002 4 56 620630 1.482 " 0.045" 2002 4 56 721631 1.19 " 4.554" 2002 4 56 843149 34.094 " 1.367" 2002 4 68 620990 .505 " 0.002" 2002 4 68 640299 .244 " 0.001" 2002 4 76 90930 25.316 " 25.000" 2002 4 76 251010 506.81 " 11333.200" 2002 4 76 300220 347.398 " 0.268" 2002 4 76 300610 .165 " 0.001" 2002 4 76 391740 27.584 " 1.528" 2002 4 76 392329 4.11 " 3.800" 2002 4 76 570110 .394 " 0.028" 2002 4 76 570210 .542 " 0.253" end
Comment