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

st: RE: RE: generating a moving sum


From   Alexander Tsai <[email protected]>
To   [email protected]
Subject   st: RE: RE: generating a moving sum
Date   Sun, 23 Nov 2003 17:29:02 -0500

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/



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