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

st: RE: nested loops for calculating a population 'at risk'


From   "Sue Lee" <[email protected]>
To   <[email protected]>
Subject   st: RE: nested loops for calculating a population 'at risk'
Date   Mon, 20 Sep 2004 18:37:29 +0100

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!

many thanks

Sue
PhD student 
London School of Hygiene and Tropical Medicine
 

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