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 11:22:22 -0400

Svend Juul's solution is short, but requires the creation of almost 1000 variables to handle three years of daily data. A more complicated solution that generates a long-format dataset in one swell foop:

clear
input admdate discdate
10000 10003
10002 10004
10001 10007
10004 10005
10004 10009
end
g daysin = discdate - admdate + 1
su daysin, meanonly
local npat = r(N)
local nrec = r(sum)
set obs `nrec'
local j 0
g daystay = .
g workload = 1
forv i=1/`npat' {
local a = admdate[`i']
local d = discdate[`i']
forv p=`a'/`d' {
local ++j
qui replace daystay = `p' in `j'/`j'
}
}
collapse (count) workload, by(daystay)
format daystay %td
list

Presumably there is a doctor-ID somewhere in here. That could also be placed on each of the long-format records so that summarization by doctor and day could take place in one step.

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