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

st: RE: Duration and panel data


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Duration and panel data
Date   Tue, 7 Oct 2003 19:00:43 +0100

miguel foguel
> 
> I'm struggling to convert a duration-type data set 
> (survival data) into a 
> "discretised" montlhy panel data. For example, suppose that 
> one individual 
> (id) displays for his first observation: (entry=1Sep1994; 
> exit=31Oct1994; 
> failure=1), and for his second observation: 
> (entry=1Nov1994; exit=30Nov1994; 
> failure=0). I want to arrange these in a typical (long) 
> panel data shape, 
> where I'd have:
> 
> id    monyear    failure
> 1    Sep1994      1
> 1    Oct1994      1
> 1    Nov1994      0
> 
> I've tried many different things but none has worked. Do 
> you have any 
> suggestion? Thanks a lot.

rename entry monyear1
rename exit  monyear2
bysort id (monyear1) : gen t = _n 
reshape long monyear, i(id t) 

Nick 
[email protected] 

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