Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
Make sure the same patients have the same id in both datasets. Even then things can go wrong, as is explained here: http://blog.stata.com/2011/04/18/merging-data-part-1-merges-gone-bad/ As you are able to tell things have gone wrong, you must be able to identify cases that do not match. My advice is to share all the information you have used to detect the missmatch(es) with Stata when merging the two datasets. Best Daniel -- I have two datasets and each has a unique id â?? the patient id. One dataset (the larger) contains patient demographic data and the other dataset (the smaller) contains the results of a laboratory test. (Not all patients had the laboratory test done). I would like to merge the two datasets. I have tried a one to one merge based on the patient id. The two datasets do merge, however a patient is paired with the wrong laboratory result (i.e. a result which is not the patientâ??s, but belonging to another patient). How can I merge the two datasets so that the two datasets are correctly merged (each patient with their correct lab result)? * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/