Thank you Nick. That was painful but worked like a charm.
Alex Tsai
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nick Cox
Sent: Sunday, November 23, 2003 12:31 PM
To: [email protected]
Subject: st: RE: generating a moving sum
I hate to say it, but a loop is one way out.
levels hospid, local(H)
levels doadmit, local(D)
gen nprev90 = .
foreach h of local H {
foreach d of local D {
qui count if hospid == `h' & doa < `d' & doa >= (`d' -
90)
replace nprev90 = r(N) if hospid == `h' & doa == `d'
}
}
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/