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

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


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   st: Re: How to merge 2 datasets using 2 unique variables
Date   Mon, 25 Apr 2005 11:06:18 -0400

I'm not sure I understand. If ssn is the only common variable, how do you determine which records match? If you do have the accident date info in both files, then it's a simple merge in Stata -- you can merge on multiple variables (see whelp merge)

use accidentdata
sort ssn accidentdate
merge ssn accidentdate using costdata

(assuming you've already sorted the costdata)

Michael Blasnik
[email protected]

----- Original Message ----- From: "Robin Newberry" <[email protected]>
To: <[email protected]>
Sent: Monday, April 25, 2005 10:43 AM
Subject: st: How to merge 2 datasets using 2 unique variables



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