Bookmark and Share

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]

Re: st: expanding a large data set and merging with another data set


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: expanding a large data set and merging with another data set
Date   Wed, 24 Apr 2013 10:33:26 +0200

On Wed, Apr 24, 2013 at 10:01 AM, David Jose wrote:
> I have two data sets, one which contains daily pollution data, and
> another which contains a data set on individuals. The individual-level
> data has information on the date of birth and date of death, and I
> would like to merge these two data sets, so that the resulting data
> set is an individual-level data set, where for each individual I have
> pollution exposure for each day of life.

So the challenge is to expand a dataset with one row per person with
only date of birth and date of death such that it has one row for each
person's day in which (s)he was alive. This is what -stsplit- is for:

*------------------ begin example ------------------
clear all
input personid    dob         dod
      1           14610       14976
      2           16557       18114
end
format dob dod %td
list

gen byte died = 1
stset dod, origin(dob) id(personid) failure(died)

stsplit time , every(1)
gen date = time + dob
format date %td

list personid dob dod date in 1/10
*------------------- end example -------------------
(For more on examples I sent to the Statalist see:
http://www.maartenbuis.nl/example_faq )

Hope this helps,
Maarten

---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index