Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fmerge / join changes using-keys>100 to missing #29

Open
cg89x opened this issue May 22, 2020 · 1 comment
Open

fmerge / join changes using-keys>100 to missing #29

cg89x opened this issue May 22, 2020 · 1 comment

Comments

@cg89x
Copy link

cg89x commented May 22, 2020

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
)

@sergiocorreia
Copy link
Owner

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 type byte, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants