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

Re: st: Re: Retrieving a master dataset after merging


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   Re: st: Re: Retrieving a master dataset after merging
Date   Sun, 10 Apr 2005 11:29:11 -0400

Good points, and obviously it would be best not to destroy your master dataset to begin with so that you could start from scratch. However, I think that in most situations you can recover the original master dataset:

1) one-to-one merge: just follow my original email suggestion of -drop if _merge==2-, -drop _merge-, -drop usingonlyvarlist-

2) one-to-many merge, do the same as (1) and then -bysort mergevarlist: keep if _n==1-

3) many-to-one merge: same solution as one-to-one merge

4) many-to-many merge -- are most likely unfixable, but you should never do this type of merge, although it could occur accidentally if you are sloppy

So, with the exception of many-to-many merges, you can retrieve the master dataset if you need to.

Michael Blasnik
[email protected]


----- Original Message ----- From: <[email protected]>
To: <[email protected]>
Sent: Sunday, April 10, 2005 7:33 AM
Subject: Re: st: Re: Retrieving a master dataset after merging



Also assuming that it's a one-to-one merge - if not the number of
observations would have increased.  Also assuming that the OP has
specified the merge correctly - again the number of observations might
have increased if there's more than one merge in the -using- data.

I think it's best to start from scratch.



Well, I don't think you should ever save the new merged dataset on top of
the master (i.e., don't use -save, replace-). If you follow this advice
then you could just -use master-. Assuming you didn't follow this advice,
you can retrieve the master dataset (if you didn't specify -update- as an
option). Just type:

keep if _merge==1 | _merge==3
drop _merge

if the using dataset contains some variables not in the master dataset,
you
then drop those:

drop usingvar1 usingvar2 usingvar3...

Michael Blasnik
[email protected]

----- Original Message -----
From: "louis boakye-yiadom" <[email protected]>
To: <[email protected]>
Sent: Saturday, April 09, 2005 12:24 PM
Subject: st: Retrieving a master dataset after merging



Dear All,
After doing a -merge-, can one retrieve the master dataset? If yes, how
can it be done? Thank you.

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