Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: RE: st: Merging 2 Tricky Panel Datasets
From
"Clifton Chow" <[email protected]>
To
<[email protected]>
Subject
st: RE: st: Merging 2 Tricky Panel Datasets
Date
Mon, 14 Mar 2011 16:29:44 -0500
I am trying to merge two panel datasets completed through in-person interviews on identiical sample of individuals, but there is one challenging component. My time variable is not easily matched. I have two such variables I can use to relate the two datasets in addition to system generated person ID:
A. Interview date - This is matched identically on both datasets, but the format for dataset 1 = mo/day/year and for dataset 2 = month, day and year are broken out into separate variables.
dataset 1 dataset 2
obs 1 04 12 09 obs 1 04/12/2009
obs 2 12 14 10 obs 2 12/14/2010
B. Interview sequence: This is the tricky part. Dataset 1 has a variable denoting interview sequence from 1- 9, but dataset 2 has interview sequence variable from 1 - 10, with 10 being the final interview conducted before discharge that can map on to the final interview recorded in dataset 1.
Dataset 1 Dataset 2
ID Seq ID Seq
obs 1 1 obs 1 1
obs 1 2 obs 1 2
obs 2 1 obs 2 1
obs 2 2 obs 2 2
OBS 2 3 OBS2 10
This means for individuals from dataset 2 without a sequence number 10, everything lines up perfectly between the two datasets (1-9). But for those with a sequence number 10, it can map on to any possible datapoint in dataset 1, depending on which is the individual's final interview as recorded in dataset 1.
Does anyone have a program (either forloop or if statement) that can handle datapoint 10 from dataset 2 so I can still successfully merge both datasets without losing significant data from individuals who were discharged (those with datapoint 10)?
Many Thanks!
*
* 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/