[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
SHANTANU NUNDY <shantanu@jhmi.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: re: working with panel data with time gaps |

Date |
Fri, 29 Feb 2008 17:26:44 -0500 |

Good afternoon, I am working with panel data and am struggling to do manipulations with the data given that the time differences between ob[n] and ob[n-1] are not constant.Here is my specific problem at hand: I have a variable that is either 1 or 0. I want to define an "episode" of 1, where episode is defined the time between the first 1 and the last 1 that is followed by at least three 0s AND over at least 21 days. From my list of 1s and 0s, I would to define a "episode_start" variable that is 1 for the start of each episode and for a second variable "episode_day" to be 1 for all days of an episode. The trouble is that in some cases the three 0s may be over 5 days and other times over 25 days. If the three 0s are over 5 days, we need to checking more observations as long as the variable remains 0 until 21 days has been reached.I have found a solution but it is by no means elegant and consists of over 20 lines of the following (where codigo is my panel variable, giardia is the 1 or 0 variab! le, giardia_i is the desire "episode_start" variable, and date is time):by codigo: replace giardia_i=1 if count_result==1 & giardia==1 & (date - date[_n-4] >= 21 | giardia[_n-4]==.) & giardia[_n-4]!=1by codigo: replace giardia_i=1 if count_result==1 & giardia==1 & (date- date[_n-5] >= 21 | date[_n-5]==.) & giardia[_n-4]!=1 & giardia[_n-5]!=1Any help would be immensely appreciated.Shantanu Nundy Hopkins SOM * * 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/

**Follow-Ups**:**Re: st: re: working with panel data with time gaps***From:*"Clive Nicholas" <clivelists@googlemail.com>

- Prev by Date:
**RE: st: Some annoying problems with my stata 10** - Next by Date:
**Re: st: RE: update to margeff** - Previous by thread:
**RE: st: Some annoying problems with my stata 10** - Next by thread:
**Re: st: re: working with panel data with time gaps** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |