0

変数を別のデータ型に置き換えるとどうなるかをテストしたかったのです。

clear
input id x0
1  1
2  13
3  .
end
list
save tabA, replace

clear
input id str5 x0
1  "1"
2  "23"
3  "33"
end
list
save tabB, replace

use tabA, clear
mmerge id using tabB, type(1:1) update replace
list

結果は次のとおりです。

   +--------------------------------------------------+
   | id   x0                                   _merge |
   |--------------------------------------------------|
1. |  1    1   in both, master agrees with using data |
2. |  2   13   in both, master agrees with using data |
3. |  3    .   in both, master agrees with using data |
   +--------------------------------------------------+

これは私には非常に奇妙に思えます。故障や不一致を予想していました。これはバグですか、それとも何か不足していますか?

4

1 に答える 1

3

mmerge is user-written (Jeroen Weesie, SSC, 2002).

If you use the official merge in an up-to-date Stata, you will get what you expect.

. merge 1:1 id using tabB, update replace
x0 is str5 in using data
r(106);

I have not looked inside mmerge. My own guess is that what you see is a feature from the author's point of view, namely that it's not a problem if one variable is numeric and one variable is string so long as their contents agree. But why are you not using merge directly? There was a brief period several years ago when mmerge had some advantages over merge, but that's long past. BTW, I agree in wanting my merges to be very conservative and not indulgent on variable types.

于 2012-11-15T12:14:26.403 に答える