Hi all,
I'm using stata 18 on windows and I'm working on bilateral trade data for 21 years, for about 200 countries. The trade commodities are coded and stringed in 2, 4 and 6 digits respectively. The 4 digits are a further specification of the 2 digits and the 6 digits also further specify the 4 digits. I'm interested in working at the 4 digit level. However, I have a list of green products given at the 6 digit code. I will like to calculate the green intensities of each 4 digits code. That is, the sum of trade values of green 6 digits within each 4 digits divided by the total trade values of their respective four digits (green + nongreen). Not all 4 digits contain at least 1 green 6 digit code, so these will be 0.
Below is an exmple dataset;
Please any ideas on how to proceed?
I'm using stata 18 on windows and I'm working on bilateral trade data for 21 years, for about 200 countries. The trade commodities are coded and stringed in 2, 4 and 6 digits respectively. The 4 digits are a further specification of the 2 digits and the 6 digits also further specify the 4 digits. I'm interested in working at the 4 digit level. However, I have a list of green products given at the 6 digit code. I will like to calculate the green intensities of each 4 digits code. That is, the sum of trade values of green 6 digits within each 4 digits divided by the total trade values of their respective four digits (green + nongreen). Not all 4 digits contain at least 1 green 6 digit code, so these will be 0.
Below is an exmple dataset;
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int year str24 reporter int reportercode str32 partner int partnercode str6 commoditycode double tradevalueus 1988 "Australia" 36 "World" 0 "01" 252106823 1988 "Australia" 36 "Argentina" 32 "01" 323513 1988 "Australia" 36 "Austria" 40 "01" 1172 1988 "Australia" 36 "Bahrain" 48 "01" 6944755 1988 "Australia" 36 "Solomon Isds" 90 "01" 4964 1988 "Australia" 36 "Brunei Darussalam" 96 "01" 4427812 1988 "Australia" 36 "Canada" 124 "01" 277546 1988 "Australia" 36 "China" 156 "01" 61070 1988 "Australia" 36 "Denmark" 208 "01" 1172 1988 "Australia" 36 "Dominican Rep." 214 "01" 1563 1988 "Australia" 36 "Fiji" 242 "01" 11695 1988 "Australia" 36 "France" 251 "01" 275017 1988 "Australia" 36 "Fmr Fed. Rep. of Germany" 280 "01" 19862 1988 "Australia" 36 "Kiribati" 296 "01" 633 1988 "Australia" 36 "China, Hong Kong SAR" 344 "01" 3032658 1988 "Australia" 36 "Indonesia" 360 "01" 5101323 1988 "Australia" 36 "Ireland" 372 "01" 1563 1988 "Australia" 36 "Israel" 376 "01" 55305 1988 "Australia" 36 "Japan" 392 "01" 16467797 1988 "Australia" 36 "Jordan" 400 "01" 37364 1988 "Australia" 36 "Rep. of Korea" 410 "01" 600145 1988 "Australia" 36 "Kuwait" 414 "01" 37574736 1988 "Australia" 36 "China, Macao SAR" 446 "01" 42795 1988 "Australia" 36 "Malaysia" 458 "01" 6890297 1988 "Australia" 36 "Mexico" 484 "01" 2657 1988 "Australia" 36 "Other Asia, nes" 490 "01" 630368 1988 "Australia" 36 "Oman" 512 "01" 6366192 1988 "Australia" 36 "Netherlands" 528 "01" 6801 1988 "Australia" 36 "New Caledonia" 540 "01" 288838 1988 "Australia" 36 "Vanuatu" 548 "01" 2345 1988 "Australia" 36 "New Zealand" 554 "01" 15600787 1988 "Australia" 36 "Norfolk Isds" 574 "01" 1252 1988 "Australia" 36 "Pakistan" 586 "01" 10480 1988 "Australia" 36 "Papua New Guinea" 598 "01" 77847 1988 "Australia" 36 "Peru" 604 "01" 1027226 1988 "Australia" 36 "Philippines" 608 "01" 3278097 1988 "Australia" 36 "Qatar" 634 "01" 10762174 1988 "Australia" 36 "Saudi Arabia" 682 "01" 86932919 1988 "Australia" 36 "India" 699 "01" 150780 1988 "Australia" 36 "Singapore" 702 "01" 3119681 1988 "Australia" 36 "So. African Customs Union" 711 "01" 7859049 1988 "Australia" 36 "Spain" 724 "01" 37524 1988 "Australia" 36 "Switzerland" 757 "01" 73348 1988 "Australia" 36 "Syria" 760 "01" 798 1988 "Australia" 36 "Thailand" 764 "01" 2145489 1988 "Australia" 36 "United Arab Emirates" 784 "01" 19618043 1988 "Australia" 36 "Fmr USSR" 810 "01" 503330 1988 "Australia" 36 "Egypt" 818 "01" 3554932 1988 "Australia" 36 "United Kingdom" 826 "01" 45992 1988 "Australia" 36 "USA" 842 "01" 1044357 1988 "Australia" 36 "US Misc. Pacific Isds" 849 "01" 13554 1988 "Australia" 36 "Uruguay" 858 "01" 12320 1988 "Australia" 36 "Venezuela" 862 "01" 979740 1988 "Australia" 36 "Fmr Arab Rep. of Yemen" 886 "01" 5787665 1988 "Australia" 36 "Areas, nes" 899 "01" 17481 1988 "Australia" 36 "World" 0 "0101" 22182487 1988 "Australia" 36 "Brunei Darussalam" 96 "0101" 10943 1988 "Australia" 36 "Fiji" 242 "0101" 3126 1988 "Australia" 36 "Fmr Fed. Rep. of Germany" 280 "0101" 7817 1988 "Australia" 36 "China, Hong Kong SAR" 344 "0101" 2741293 1988 "Australia" 36 "Indonesia" 360 "0101" 261799 1988 "Australia" 36 "Japan" 392 "0101" 557610 1988 "Australia" 36 "Rep. of Korea" 410 "0101" 600145 1988 "Australia" 36 "Malaysia" 458 "0101" 146255 1988 "Australia" 36 "Other Asia, nes" 490 "0101" 48893 1988 "Australia" 36 "New Caledonia" 540 "0101" 20169 1988 "Australia" 36 "New Zealand" 554 "0101" 14500923 1988 "Australia" 36 "Papua New Guinea" 598 "0101" 25797 1988 "Australia" 36 "Philippines" 608 "0101" 81838 1988 "Australia" 36 "Singapore" 702 "0101" 1179131 1988 "Australia" 36 "Spain" 724 "0101" 37524 1988 "Australia" 36 "Thailand" 764 "0101" 1031317 1988 "Australia" 36 "United Kingdom" 826 "0101" 2345 1988 "Australia" 36 "USA" 842 "0101" 925172 1988 "Australia" 36 "Areas, nes" 899 "0101" 390 1988 "Australia" 36 "World" 0 "010111" 12886335 1988 "Australia" 36 "Brunei Darussalam" 96 "010111" 6253 1988 "Australia" 36 "Fiji" 242 "010111" 3126 1988 "Australia" 36 "Indonesia" 360 "010111" 88598 1988 "Australia" 36 "Japan" 392 "010111" 30754 1988 "Australia" 36 "Rep. of Korea" 410 "010111" 156930 1988 "Australia" 36 "Malaysia" 458 "010111" 24312 1988 "Australia" 36 "New Caledonia" 540 "010111" 20169 1988 "Australia" 36 "New Zealand" 554 "010111" 12058621 1988 "Australia" 36 "Philippines" 608 "010111" 81838 1988 "Australia" 36 "Singapore" 702 "010111" 174330 1988 "Australia" 36 "Spain" 724 "010111" 37524 1988 "Australia" 36 "Thailand" 764 "010111" 203880 1988 "Australia" 36 "World" 0 "010119" 9287476 1988 "Australia" 36 "Fmr Fed. Rep. of Germany" 280 "010119" 7817 1988 "Australia" 36 "China, Hong Kong SAR" 344 "010119" 2741293 1988 "Australia" 36 "Indonesia" 360 "010119" 173201 1988 "Australia" 36 "Japan" 392 "010119" 526856 1988 "Australia" 36 "Rep. of Korea" 410 "010119" 443215 1988 "Australia" 36 "Malaysia" 458 "010119" 121943 1988 "Australia" 36 "Other Asia, nes" 490 "010119" 48893 1988 "Australia" 36 "New Zealand" 554 "010119" 2442302 1988 "Australia" 36 "Papua New Guinea" 598 "010119" 25797 1988 "Australia" 36 "Singapore" 702 "010119" 1004801 1988 "Australia" 36 "Thailand" 764 "010119" 823451 end
Please any ideas on how to proceed?
Comment