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

Re: st: How to merge 2 datasets using 2 unique variables


From   Nick Winter <nw53@cornell.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: How to merge 2 datasets using 2 unique variables
Date   Tue, 26 Apr 2005 09:26:45 -0400

Easy: Stata can match on more than one variable. Just sort both datasets on both variables, then list both in the -merge- command:

. merge ssn adate using ...

--Nick Winter

. At 09:16 AM 4/26/2005 -0400, you wrote:

Folks,

I've 2 datasets I need to merge (one with accident data and one with cost data), but the one "unique" variable they have in common (Social Security Number) won't work since there are multiple occurrences of the same individual. What I need to do is merge on two variables - like SSN and accident date - but I can't figure out how to do this in Stata. Is there a way, or do I need to merge the datasets outside of Stata (in Excel, for example) and import them?.
--
Robin
--------------------------------------------------------------
W. Robert Newberry, IV CIH, CHMM
Chief Environmental Health and Safety Officer
Clemson University

wnewber@clemson.edu ehs@clemson.edu
http://ehs.clemson.edu/
*
* 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/
--------------------------------------------------------
Nicholas Winter 607.255.8819 t
Assistant Professor 607.255.4530 f
Department of Government nw53@cornell.edu e
308 White Hall falcon.arts.cornell.edu/nw53 w
Cornell University
Ithaca, NY 14853-4601

*
* 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index