Hi there,

I was trying to merge two datasets (code:joinby), however it seems that stata cannot identify my key variable.
The master dataset looks as follows:
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float id str12 inventor_id int nodes float(_degree dg_central)
2 "4677061_3" 455  .05947137 .04970777
3 "4891185_1"  16         .6  .2857143
4 "5281603_1" 662 .031770047 .02461376
4 "3956484_2" 662 .031770047 .02461376
5 "5321008_2"  11         .4 .24444444
end
The using dataset as follows:
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str12 inventor_id float(id kd_4)
"4013665-2" 1934 .2738613
"4381297-1" 1934 .3535534
"4464380-1" 1934 .3535534
"4571404-1" 1934 .4950738
"4985433-4" 1934        0
end
The merged results are:
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str12 inventor_id float(id kd_4) byte _merge int nodes float(_degree dg_central)
"4677061_3" 2 . 2 455  .05947137 .04970777
"4891185_1" 3 . 2  16         .6  .2857143
"3956484_2" 4 . 2 662 .031770047 .02461376
"5281603_1" 4 . 2 662 .031770047 .02461376
"5124314_1" 5 . 2  11         .4 .24444444
end
label values _merge __MERGE
label def __MERGE 2 "only in using data", modify

The code is:
Code:
joinby id inventor_id using " `temp1' ", unm(m)
The matched results include only obervations in master data, non-of the observations in using data has been matched. I'm pretty sure that the id and inventor_id in master dataset are matched with the observations in using data (and inventor_ids in master dataset are a small proportion of observations from using data). It seems that my inventor_id in both datasets are not identical so that they cannot be matched. I further tried
Code:
replace inventor_id = trim(itrim(inventor_id))
for both datasets, but it does not help. Also, you may suggest
Code:
destring inventor_id, replace
tostring inventor_id
I cannot do that because the variable inventor_id includes both numeric and non-numberic characters.

Any ideas will be highly appreciated.