Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: merging two data sets


From   David Jose <davidjosework@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: merging two data sets
Date   Fri, 22 Mar 2013 08:50:22 +0100

Supoose that in data set 1, I have for each observation a personid and
his date of birth and date of death.

For example, for persons 1 and 2:

personid    dob         dod

1               1/1/00    1/1/01

2               5/1/05    8/5/09


In data set 2, I have information on, say, a daily pollution measure
for each day of every year. The (dob, dod) pair of dates in data set 1
is always a subset of the time range in data set 2.

For example, for the month of January in 2000:

time          pollution

1/1/00        50
1/2/00        49.5
.
.
.
12/31/10        65

I would like to merge these two data sets. The resulting merged data
set would have, for each person, the pollution level for each day of
life. That is, I'd like the merged data set to look like this:

personid    dob         dod     time          pollution

1               1/1/00    1/1/01  1/1/00        50
1               1/1/00    1/1/01  1/2/00        49.5
.
.
.
1               1/1/00    1/1/01  1/1/01        55

2               5/1/05    8/5/09  5/1/05        65
2               5/1/05    8/5/09  5/2/05        62
.
.
.
2               5/1/05    8/5/09  8/5/09        69

etc. etc.

What would be the most efficient way to complete this task?

Thanks in advance for any advice.


Best,

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


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