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

From |
"Maria Montez" <montez@bu.edu> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: creating an array with hospitalization days |

Date |
Tue, 8 Nov 2005 14:56:48 -0500 |

Hi! I'm still on v8. I'm looking at one year of data for which one record corresponds to one hospitalization. I created variables day1-day365 to represent all the days in that year. Now, I would like those variables to be equal to one during an hospitalization. I have the admission day (admitday) and the discharge day (disday) and using these, I created two variables begin and end that tell me when did that hospitalization started and ended. Then I though that I could loop from begin to end and change the day array from 0 to 1. However I'm getting a syntax error and I think it comes from the begin and end variables in the forvalues loop. Can anyone help me? sample code: forvalues i=1(1)365 { gen day`i'=0 } gen begin=admitday-mdy(10,1,2000)+1 replace begin=1 if begin<=0 gen end=disday-mdy(10,1,2000)+1 forvalues i=begin(1)end { replace day`i'=1 } sample data: +--------------------------------------------------------------+ | study_id admitday disday begin end day1 day2 | |--------------------------------------------------------------| 1. | 19 03jan2001 24jan2001 95 116 0 0 | 2. | 362 24may2001 29may2001 236 241 0 0 | 3. | 396 01jun2001 07jun2001 244 250 0 0 | 4. | 436 21mar2001 22mar2001 172 173 0 0 | 5. | 438 17jan2001 25jan2001 109 117 0 0 | |--------------------------------------------------------------| 6. | 517 06mar2001 21mar2001 157 172 0 0 | 7. | 517 11sep2001 17sep2001 346 352 0 0 | 8. | 590 16sep2001 17sep2001 351 352 0 0 | 9. | 879 20dec2000 22dec2000 81 83 0 0 | +--------------------------------------------------------------+ * * 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: creating an array with hospitalization days***From:*"Eric G. Wruck" <ewruck@econalytics.com>

**References**:**st: Re: RE: Re: RE: Re: RE: summing up matrix elements***From:*"R.E. De Hoyos" <redeho@hotmail.com>

- Prev by Date:
**st: Re: RE: Re: RE: Re: RE: summing up matrix elements** - Next by Date:
**Re: st: creating an array with hospitalization days** - Previous by thread:
**st: Re: RE: Re: RE: Re: RE: summing up matrix elements** - Next by thread:
**Re: st: creating an array with hospitalization days** - Index(es):

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