Hi all,
I am working on a cross-country dataset. The dataset is created when I merge the bilateral trade data with the country characteristics (such as GDP and bilateral trade agreements). When I merge I use the exporter ISO code, the importer ISO code and time as the identifiers. My master data is the trade data and my using data is the characteristics data. In the using data I rename the country of origin the exporter and the country of destination the importer. For instance, in the merged data I will have the trade value exported by country A to country B, the GDP of country A and of country B and whether A and B have a trade agreement. However, what the data misses is when B exports to A I don't have the characteristics because the using data already considers A as the origin and B as the destination (due to the way I rename the variables in the using data). I cannot merge the data one more time with A being the destination and B as the origin because of duplication (the free trade agreement variable will appear twice). I was then thinking of replacing the missing observation when B exports to A by the value of the observation when A exports to B thanks to symmetry. I checked on the forum and what I can find is I need know the ID of the observation (i.e. replace GDP = GDP[6]). In my case, I only know the observation satisfies certain conditions: replace GDP = GDP of the observation whose Exporter=Importer and Importer=Exporter.
To illustrate my point, here is an example:
Before:
Exporter Importer Exporter_GDP Importer_GDP Trade value
A B 100 200 50
B A . . 70
After
Exporter Importer Exporter_GDP Importer_GDP Trade value
A B 100 200 50
B A 200 100 70
Could you please give me some suggestions?
Many thanks,
Gia Cat Luong
Related Posts with Replacing missing variable with other observations that satisfy certain conditions
Panel Structural VARHello all, I am working on finding the us monetary policy impact on a bunch of countries and for thi…
xtabond2: interpretation of Arellano-Bond test using forward orthogonal deviationsI've been trying to understand the interpretation of the Arellano-Bond test when using FOD for syste…
Problem with lpolyci graph using Stata 15 vs 17Hi everybody! I am using Stata 17. While running the code below: HTML Code: sysuse auto, clear …
Generating mean of a variable (e.g. population density) for each observation, when each observation spans multiple states/provinces.Hi all, I am trying to create a mean population density variable for every observation in my datase…
Renaming variables in loopHello all, I'm working with a dataset which has variables with counters as follows: payment_1, paym…
Subscribe to:
Post Comments (Atom)
0 Response to Replacing missing variable with other observations that satisfy certain conditions
Post a Comment