Hi all
I have hospital data from a number of institutions with one row per hospital stay, an admission date and a discharge date:
UNIT DATEIN DATEOUT
APAH 30oct2012 31oct2012
APAH 01nov2012 24dec2012
APAH 07nov2012 14nov2012
HPPH 12mar2004 19mar2004
HPPH 08mar2004 18mar2004
HPPH 28feb2004 04mar2004
PEAH 05dec2012 01jan2013
PEAH 05dec2012 12jan2013
PCAH 23dec2003 03jan2004
PCAH 15jan2004 21jan2004
etc.
I also have an history of the number of existing hospital beds in these institutions.
DATE NROFBEDS
01jan2000 70
01jun2001 75
01oct2006 80
etc.
There is no bed number in the dataset.
I would like to plot
1) the number of occupied and unoccupied beds against calendar date
2) the bed occupancy rate against calendar date
I have used the following code to obtain the number of patient*days each year, but I would also like to plot monthly and daily values.
Does any of you know of a less tedious way to solve the problem?
_________________
gen id=_n
gen fail=1
stset DATEOUT,fail(fail) enter( DATEIN ) id(id)
forvalue YEAR=1998/2012{
display date("1/1/`YEAR'", "MDY")
} // in order to check for the time codes at which I need to split the observations
stsplit YEAR, at(13880 14245 14610 14976 15341 15706 16071 16437 16802 17167 17532 17898 18263 18628 18993) //splitting on jan 1st each year
replace YEAR=yofd(Annee_jours) // replaces 1/1/2003 --> 2003, etc
format _t _t0 %td
gen DAYS= _t-_t0
collapse (sum) DAYS,by(YEAR) //gives me the number of patient*days per year
I have hospital data from a number of institutions with one row per hospital stay, an admission date and a discharge date:
UNIT DATEIN DATEOUT
APAH 30oct2012 31oct2012
APAH 01nov2012 24dec2012
APAH 07nov2012 14nov2012
HPPH 12mar2004 19mar2004
HPPH 08mar2004 18mar2004
HPPH 28feb2004 04mar2004
PEAH 05dec2012 01jan2013
PEAH 05dec2012 12jan2013
PCAH 23dec2003 03jan2004
PCAH 15jan2004 21jan2004
etc.
I also have an history of the number of existing hospital beds in these institutions.
DATE NROFBEDS
01jan2000 70
01jun2001 75
01oct2006 80
etc.
There is no bed number in the dataset.
I would like to plot
1) the number of occupied and unoccupied beds against calendar date
2) the bed occupancy rate against calendar date
I have used the following code to obtain the number of patient*days each year, but I would also like to plot monthly and daily values.
Does any of you know of a less tedious way to solve the problem?
_________________
gen id=_n
gen fail=1
stset DATEOUT,fail(fail) enter( DATEIN ) id(id)
forvalue YEAR=1998/2012{
display date("1/1/`YEAR'", "MDY")
} // in order to check for the time codes at which I need to split the observations
stsplit YEAR, at(13880 14245 14610 14976 15341 15706 16071 16437 16802 17167 17532 17898 18263 18628 18993) //splitting on jan 1st each year
replace YEAR=yofd(Annee_jours) // replaces 1/1/2003 --> 2003, etc
format _t _t0 %td
gen DAYS= _t-_t0
collapse (sum) DAYS,by(YEAR) //gives me the number of patient*days per year
Comment