Hello dear stata friends, we are pretty new on stata and would like some help.
We managed to merge two data sets, (where the first data set consisted of Import Exporter Year Imports and the second one of Distance between the countries). Like this:
Importer Exporter Year Imports Distance
Austria Albania 2005 4843 812
Sweden Norway 2005 1084 417
Austria Albania 2006 4900 812
Sweden Norway 2006 1100 417
This continues for 28 importing countries and 170 exporting countries from 2004-2016 with 59623 observations. Our code looked like this and it worked fine:
use distancemaster.dta
sort Importer Exporter
save, replace
use masterfile.dta
sort Importer Exporter
save, replace
merge Importer Exporter using distancemaster.dta
drop _merge
save testingdistance, replace
Now we want to add GDP for Importer and Exporter, (we have two GDP data sets, one with Exporter from year 2004-2016 and one with Importer from year 2004-2016) we used this commando:
use BNProw.dta
sort Exporter Year
save, replace
use masterfile.dta
sort Exporter Year
save, replace
merge Exporter Year using BNProw.dta
save testinggdprow, replace
When we tried this commando, an error message errupted:
key variable Year is int in master but str4 in using data
Each key variable -- the variables on which observations are matched --
must be of the same generic type in the master and using datasets. Same
generic type means both numeric or both string.
What are we doing wrong and how can we solve it?
Best regards,
Gabriel and Hanna.
Related Posts with Merge problems
Standerdized diffrence calculation in complex weighted dataHey guys, I am trying to calculate the standardized differences in complex weighted data. I was abl…
Interpolating missing dataCan we interpolate missing data for central bank policy rate by using leading rate or any other econ…
margins at percentilesHi Statalists, I have code like this: Code: regress y x1 x2 x3 egen p10 = pctile(x1), p(10) egen …
FE with four-way error-componentsHello everyone, I am estimating a DiD (difference in difference) with Least-squares dummy-variables…
PPML Gravity Model: interacting continuous variablesGood afternoon! I am estimating a PPML gravity model of trade adding an index of ethnic fractionalis…
Subscribe to:
Post Comments (Atom)
0 Response to Merge problems
Post a Comment