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
Stata 15.1 close after exceeding the limit of scrollbufsizeI have noticed that the Stata suddenly close and loosing my unsaved do files. I think it is because …
Using response weights (svy) on a linear regression (regress) but want beta valuesI am using a large dataset (5000+) survey data with weights accounting for demographics that were un…
Random effect logistic regressionHi everyone I have recently started to use Stata, and confused about how I should interpret the res…
Merging 2 datasets on overlapping period of timeI have a question related to merging two datasets on an overlapping period of time. I have found som…
modelling "indirect" social networksI have a dataset of physicians working in different hospitals in different teams. A physician can wo…
Subscribe to:
Post Comments (Atom)
0 Response to Merge problems
Post a Comment