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

Re: st: re: counting patient-days--resolved

From   "Christopher W. Ryan" <>
Subject   Re: st: re: counting patient-days--resolved
Date   Sun, 07 Aug 2005 17:36:38 -0400

Michael Blasnik's method was simple and worked great. Thank you for your help.
Christopher W. Ryan, MD
SUNY Upstate Medical University Clinical Campus at Binghamton
and Wilson Family Practice Residency, Johnson City, NY
GnuPG and PGP public keys available at

"If you want to build a ship, don't drum up the men to gather wood, divide the work and give orders. Instead, teach them to yearn for the vast and endless sea." [Antoine de St. Exupery]

Kit Baum wrote:

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

* For searches and help try:

*   For searches and help try:

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