[EpiData-list] EpiData-list Digest, Vol 127, Issue 9

epidata-list at lists.umanitoba.ca epidata-list at lists.umanitoba.ca
Sat Jun 14 15:09:36 CDT 2014


As far as I can tell, there is no simple way to do this in Analysis (i.e. with a command like aggregate). The challenge is that you have patient-oriented data, with one record representing multiple bed-days and you want to massage this into day-oriented data. Aggregate is meant for data where each patient record has a variable that can take on multiple values. You don’t have any values for the days between admission and discharge.

However, I suggest the following, along the lines of what you have done already.

before you print anything, add this (outside the CMD):

set echo=off
logopen “roomdata.txt” /replace
type “aday, acount, apct”

Then replace your type within the CMD with:

type “ @day, @$count, @pct”

What you will print out is comma-delimited data like this:

aday, acount, apct
2014/06/10, 8, 88.888
2014/06/11, 7, 77.777
2014/06/12, 9, 100

Now, get it all back into Analysis:

logclose
close
set echo=on
copyfile “roomdata.txt” “roomdata.csv” /replace
read “roomdata.csv”
* date comes in OK, but numbers are read as strings
define icount ##
define xpct ###.#
icount = integer(acount)
xpct = float(apct)

You will now have a data set in Analysis with the fields
aday, acount, apct, icount, xpct
date  string    string integer float

You can actually program your calculation of bed occupancy for an arbitrary number of days and use imid within the CMD to loop through the data. A CMD file can refer to itself! Yes, Analysis, for all its apparent simplicity, allows recursive functions! Jens and I have explained how to use this in the examples of using CMD and also on the list serve: http://lists.umanitoba.ca/pipermail/epidata-list/2009q2/001220.html
Try the recursive function - I think you may have to program it to count down from the current date, as the recursive function may otherwise output the data in reverse order.

So you can accomplish all of this automatically, once you establish a start date and number of days to cover.

Jamie

On Jun 13, 2014, Vegard wrote:

> Defining custom command mycmd01 fas very helpful calculating hospital ward
> utilization starting av certain day:
> 
> CMD mycmd01
> count if (inndato <= aday) and (utdato >= aday)
> pct=$count/9*100 //Percent utilization of a 9 bed ward
> type "Beds occupied on @aday : @$count Percent filled : @pct"
> *** Next statement adds a line to aggregate file
> sday = sday + $count
> aday = aday + 1
> end
> 
> // repeating this command necessary number of times.
> 
> To take this even further, I try to produce a SPC graph of utilization rate
> variation over time.
> 
> I thought that I will need an aggregate file with 2 variables: Counting
> date (aday) and Count (of beds each day).
> 
> I have tried to use aggregate command combined with repeating the CMD
> segment obove, but it fails.
> 
> i have also tried to define a new REC file containing the two variables
> aday (or inndato) and beds=$count, and put this command into the mycmd01
> block:
> 
> append aday beds /file="aggfile.rec"
> 
> I have trouble understanding the EpiDaat Process flow...
> 
> Any hints?
> 
> best regards,
> Vegard



More information about the EpiData-list mailing list