Statalist


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

Re: st: merge: "variable does not uniquely identify observations in the master data"


From   Phil Schumm <[email protected]>
To   [email protected]
Subject   Re: st: merge: "variable does not uniquely identify observations in the master data"
Date   Tue, 8 Jul 2008 21:12:20 -0500

On Jul 8, 2008, at 6:46 PM, Jeff Pflueger wrote:
If I do this, I get the error I would expect:

use "$people", clear
merge householdno using "$household", uniqmaster sort

the error is in red on the command line and it terminates my do-file.
It says: "variable householdno does not uniquely identify observations in the master data"

Makes sense, the master dataset does not contain unique householdno's but the household dataset does.

But if I do this:

use "$people", clear
merge householdno using "$household", uniqusing sort

I get the same error: "variable householdno does not uniquely identify observations in the master data" but in this case, the do- file continues to run, and the error message is in green, not red.

In the first case, you're getting an error because you specified the - uniqmaster- option and the variable householdno does not uniquely identify the observations in $people. In the second case, you're merely getting an informative message; -merge- always gives such a message when the observations in either dataset are not uniquely identified by the variable(s) you are merging on. You may ignore this message if you are intentionally performing a one-to-many or many-to-one merge.



But householdno is unique in the master dataset....

When I:
use "$household", clear
duplicates list householdno

I get this:

Duplicates in terms of householdno

(0 observations are duplicates)

This is entirely consistent with what you have shown us above -- in those calls to -merge-, $household is not the master dataset, $people is.


-- Phil

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




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