Dear Clyde Schechter
I am working with international trade data. Each observation is an export flows from country i to country j at time t.
DATA 1
For each year. I need to create an additional obervation on domestic trade flows i = j.
The domestic trade is calculated as
Xii = GDPit - Σ j# i Xijt
that is domestic trade Xii (i = j) is the difference between GDP of exporter and sum of all its exports to the world (Σ j# i Xijt).
In this example, USA in 1990 is exporting to FRA, DEU, and GBR. I aggregate the export flows of USA across all partners to obtain the total exports of USA to the rest of world in year 1990 (i.e., Σ j# i Xijt = 1.7 + 3.2 + 2.5 = 7.4). The GDPUSA,1990 = 10.5 , therefore dometic trade flows are obtained as:
ExportsUSA-USA,1990 = GDPUSA,1990 - Σ j# i Xijt = 10.5 - 7.4 = 3.1
Following same procedure for other countries, will give us a data like
DATA 2
How do I get from DATA 1 to DATA 2.
Thanks and regards,
(Ridwan)
I am working with international trade data. Each observation is an export flows from country i to country j at time t.
DATA 1
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str3(iso_i iso_j) int Year double(GDP_it Exports_ijt) "USA" "FRA" 1990 10.5 1.7 "USA" "DEU" 1990 10.5 3.2 "USA" "GBR" 1990 10.5 2.5 "DEU" "PRT" 1990 20.3 9.4 "DEU" "USA" 1990 20.3 6.7 "DEU" "LTU" 1990 20.3 5.9 "USA" "FRA" 1991 13.7 8.6 "USA" "TUN" 1991 13.7 3.2 "USA" "GBR" 1991 13.7 9.5 "DEU" "GBR" 1991 22.4 7.3 "DEU" "USA" 1991 22.4 8.4 "DEU" "LTU" 1991 22.4 3.5 end
For each year. I need to create an additional obervation on domestic trade flows i = j.
The domestic trade is calculated as
Xii = GDPit - Σ j# i Xijt
that is domestic trade Xii (i = j) is the difference between GDP of exporter and sum of all its exports to the world (Σ j# i Xijt).
In this example, USA in 1990 is exporting to FRA, DEU, and GBR. I aggregate the export flows of USA across all partners to obtain the total exports of USA to the rest of world in year 1990 (i.e., Σ j# i Xijt = 1.7 + 3.2 + 2.5 = 7.4). The GDPUSA,1990 = 10.5 , therefore dometic trade flows are obtained as:
ExportsUSA-USA,1990 = GDPUSA,1990 - Σ j# i Xijt = 10.5 - 7.4 = 3.1
Following same procedure for other countries, will give us a data like
DATA 2
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str3(iso_i iso_j) int Year double(GDP_it Exports_ijt) "USA" "FRA" 1990 10.5 1.7 "USA" "DEU" 1990 10.5 3.2 "USA" "GBR" 1990 10.5 2.5 "USA" "USA" 1990 10.5 3.1 "DEU" "PRT" 1990 20.3 9.4 "DEU" "USA" 1990 20.3 6.7 "DEU" "LTU" 1990 20.3 5.9 "DEU" "DEU" 1990 20.3 -1.7 "USA" "FRA" 1991 13.7 8.6 "USA" "TUN" 1991 13.7 3.2 "USA" "GBR" 1991 13.7 9.5 "USA" "USA" 1991 13.7 7.6 "DEU" "GBR" 1991 22.4 7.3 "DEU" "USA" 1991 22.4 8.4 "DEU" "LTU" 1991 22.4 3.5 "DEU" "DEU" 1991 22.4 3.2 end
Thanks and regards,
(Ridwan)
Comment