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
0 Response to Replacing missing variable with other observations that satisfy certain conditions
Post a Comment