Many thanks to those kind souls who responded to my initial query... i
think perhaps i was not clear enough about what i am trying to do... so
i'll try explaining again!
the dataset contains a record for each baby born on each day from 1988
to 2000. we have a variable for birthdate and a variable for gestation
at birth in days (dgest).
i am interested in how to generate the following algorithm into
workable STATA code:
1. for each date from 1 jan 1988 to 31 dec 2000
2. calculate the number of records that have dgest > 167 and < 259 on
the current day (these are the 'cases at risk')
3. move forward a day
4. increase both dgest values by 1 and repeat step 2 (i.e., calculate
the number of records on this day that have dgest > 168 and <260...
these are the cases that were 'at risk' the day before)
5. move forward a day
6. repeat step 4 and 5 until max dgest value reached
7. sum the number of records 'at risk' for each day
i'd be most grateful for any help or suggestions received!
If I understand correctly -- that the bounds 167 and 259 apply to
02jan1988, and 168 and 260 apply to 02jan1988, and so on, then try this:
(I'm not sure if this is right, since this will lead to absurdly long
gestation limits. But then you just get nobody at-risk after some point.)