Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: merging datasets and getting different N in resulting dataset if I run several times


From   "Michael I. Lichter" <mlichter@buffalo.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: merging datasets and getting different N in resulting dataset if I run several times
Date   Fri, 14 Aug 2009 12:09:58 -0400

Woolton,

It would be helpful if you could specify what you want the resulting dataset to look like. Do you want a record for every matching pair of records, as you would get with -joinby- or do you want something else? It would also be helpful if you could show your exact command syntax.

Michael

Nick Cox wrote:
If as you say the id variables do not uniquely identify observations in either dataset, it does not seem at all surprising that you get results like this. The assertion that there is be a bug, on no firm evidence whatsoever, is unconvincing in these circumstances. Either way, better advice might be forthcoming if you showed (a portion of) data for which you get results that puzzle you. Nick n.j.cox@durham.ac.uk
Woolton Lee

I am using 6 id variables to merge, all of which were character and I
have now converted them to numeric.  Even after I switch to stable
sorting and numeric id variables the problem persists though it is
smaller in magnitude - previously I was getting differences of 5-9 obs
in the resulting dataset between different runs, now its more like 1.
The id variables do not uniquely identify observations in the master
or using dataset.  Having said that it seems to me that this should
not occur at all even if there is duplication, and I am at a loss to
understand why its occurring.  A colleague of mine suggested there is
a bug in the merge command, I am using STATA 9.

On Fri, Aug 14, 2009 at 10:44 AM, Austin Nichols<austinnichols@gmail.com> wrote:

Probably due to unstable sorting; without further info, hard to diagnose.
Do you have missing values in any of the merge vars?
This is a potentially very serious problem; see e.g.
#4 in http://www.princeton.edu/~jrothst/hoxby/rejoinder.pdf

On Fri, Aug 14, 2009 at 10:28 AM, Woolton Lee<finished07@gmail.com> wrote:
Hi I am getting a problem where I am merging two datasets together and
the N in the resulting dataset can change if I rerun the program 2 or
more times.  I am merging by company code (COCODE) and year which do
not uniquely identify observations in the using dataset, but it seems
to me that that should not matter.  I get the same result if I use the
joinby command - the resulting N in the dataset changes if I rerun the
program.  I am trying to understand why this might happen and am
stumped at the moment.  Does anyone have any suggestions?

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

--
Michael I. Lichter, Ph.D. <mlichter@buffalo.edu>
Research Assistant Professor & NRSA Fellow
UB Department of Family Medicine / Primary Care Research Institute
UB Clinical Center, 462 Grider Street, Buffalo, NY 14215
Office: CC 126 / Phone: 716-898-4751 / FAX: 716-898-3536

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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