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

st: re: counting patient-days


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: re: counting patient-days
Date   Wed, 20 Jul 2005 15:36:16 -0400

Michael said

I think there is a simpler solution than the ones proposed.

gen los=dischargedate-admitdate+1
gen date=admitdate
expand los
bysort patientid: replace date=date[_n-1]+1 if _n>1

you now have a dataset with one observation per patient per day where you
can count the number of days, etc..


That is indeed more elegant and Stataish. Like my proposal, it creates a long format dataset rather than hundreds of new variables.

Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html

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