Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Merge data


From   Ernest Berkhout <[email protected]>
To   [email protected], [email protected]
Subject   Re: st: Merge data
Date   Thu, 13 Nov 2003 11:30:15 +0100

At 04:57 12-11-2003, Lok Wong wrote:
Hi,there,

I have one question about merging data..I am wondering if someone out there could help me with it.

Let's say data sets, A and B.. A includes {X1,X2,X3,X4} and B includes{X1,X2,X5}..Using X1 and X2, we could uniquely identify the individuals in the data...Moreover,the sample size of B is bigger that of A..I only want X5 of individuals in B who are also in A...How could I do this?
If you are doing this regularly, it pays to download -mmerge.ado- which enables you to do it all on one commandline, including specific safety checks to see if the merge process does what you want:

use datasetA
mmerge X1 X2 using datasetB, ukeep(X5) type(1:1) unmatched(master)

ukeep -> merges only X5, no other variables that might be in your using dataset
type(1:1) -> checks that each record is indeed uniquely identified by your matchkey-variables (X1 & X2)
unmatched -> tells Stata that if records do not match exactly it should only keep the record of the master dataset. That is, no 'new' records are appended from the using dataset (B) with combinations of X1-X2 that were not in the master dataset (A) already.

I believe that the build-in -merge- can do such things as well since Stata 8, but I'm not sure about that as I always use -mmerge.ado-.



Ernest Berkhout
SEO Amsterdam Economics
University of Amsterdam

Room 3.08
Roetersstraat 29
1018 WB Amsterdam
The Netherlands

tel.:+ 31 20 525 1657
fax:+ 31 20 525 1686
http://www.seo.nl
===========================
A statistician: someone who insists
on being certain about uncertainty
===========================

*
* 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