fmerge / join changes using-keys>100 to missing
Opened this issue · 1 comments
Hi Sergio,
I found a rather weird bug in the fmerge/join command:
Let's say I have a numeric ID ranging from 1 to X where X>100. In the Master data, the ID is always <100 but in the Using data the ID can be > 100. The fmerge/join works, however, it will change all IDs > 100 to missing in the final data. This behavior does happen in all join into/from combinations.
I attached an example code and data.
Best,
Chris
bugexample.zip
(ftools header: *! version 2.37.0 16aug2019,
join header: *! version 2.36.1 13feb2019,
fmerge header: *! version 2.10.0 3apr2017,
stata version 15 mp,
mac osx
)
clear all
set obs 3
gen int id = _n
replace id = 200 in 3
gen y = 10 * _n
li
tempfile using
save "`using'"
clear
set obs 3
gen byte id = _n + 1
gen z = 100 * _n
li
de
fmerge 1:1 id using "`using'"
li
de
I could replicate it. This is what's happening:
- The ID in
master
is of typebyte
, which allows values up to 100 (help byte
). - The ID in
using
is of another type, allowing larger numbers - While merging,
fmerge
does not recast the ID from byte to e.g. int.
It should be an easy fix, but a quick workaround would be to do e.g. recast int id
(where id is your identifier) right before merging.