[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: -collapse- and -merge-

From   Philipp Rehm <>
Subject   st: -collapse- and -merge-
Date   Sat, 03 Nov 2007 09:35:05 -0400

I am regularly puzzled by a particular feature of -merge-, namely to match missing observations with each other. Here is an example:

sysuse auto, clear
sort price
keep in 1/15
replace foreign=. in 1/5

collapse (mean) PRICE=price, by(foreign)
sort foreign
tempfile m
save `m'

sort foreign
merge foreign using `m'

list foreign PRICE

I can avoid this problem in various ways (a "drop if foreign==." after the -collapse- would be one option). I also understand that Stata reads missing values as very large numbers (i.e.: all nonmissing numbers < . < .a < .b < ... < .z). I do not understand, however, why it matches missing values with each other. Moreover, the same behavior persists when I specify the -merge- option "uniqusing".

Let me add that this behavior does not seem as strange in the example above. However, I usually -merge- data from totally different data-sources. There is no logical pattern to the missing values, and no reason to match them.

Am I missing something? Clarifications are appreciated.


* For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index