Re: [EpiData-list] Entering time and date for outbreaks
Hi Charity
Thanks very much for your formula. Its sounds really good. I had a go at putting it in a check file. Following through your example below 'Diatime' is my 'vtime2' and 'diadate' is my vdate2. I thought I would start off slowly by seeing if I coudl calculate Vhours2. I created a new field called Vhours2 in my rec file and then I put the following code into the check file.
DIATIME AFTER ENTRY LET VHOURS2=INT(DIATIME)+(FRAC(DIATIME)/0.6)+(DIADATE*24) END END
Epi accepted the code but nothing appears in the vhours2 field when I enter information in the diadate and diatime fields. Can you see what I am doing wrong?
thanks
Christine Roseveare Analyst Regional Public Health 570 9194 027 495 9671
epidata-list@lists.umanitoba.ca 26/02/2007 7:24 p.m. >>>
Hello Chrsitine,
I prefer to enter times as a decimal field, i.e. ##.##. I can then put checks in place to make sure the minutes are in correct time format e.g. IF Frac(vtime) > 0.59 THEN ....
Based on this decimal 24 hour time format, I have a formula which you can use to calculate the difference in hours between two time and date combinations.
Assume that your first time and date are vtime1 and vdate1, and your second time and date are vtime2 and vdate2:
First calculate the number of hours (since 31st December 1899) for both time and date combinations (store them as vhours1 and vhours2) using the following formulae:
vhours2=Int(vtime2) + (Frac(vtime2)/0.6) + (vdate2*24) vhours1=Int(vtime1) + (Frac(vtime1)/0.6) + (vdate1*24)
And then you can just calculate the time difference /incubation period into a different variable!
timediff=vhours2-vhours1
You could also have done something similar and perhaps simpler using EpiData's Time2Num function which will convert a decimal time into a number between 0 and 1 representing a fraction of a day - I just prefer to work with hours.
To explain the hours calculation formula for you (only need to read below if you care how the formula works): Int(vtime) takes the integer part of the time, and Frac(vtime) takes the fractional part of the time. These are separated so Frac(vtime) alone can be converted from minutes into fraction of an hour (e.g. from 0.30 to 0.50). The date integer (representing the number of days since 31 Dec 1899) is then multiplied by 24 to get the number of hours since 31 Dec 1899. This 1899 date is relevant only because it is how EpiData stores the date as an integer - we do not have to worry about this because we only care about the difference between the two dates.
Hope this helps!
Charity
Charity Jenkins Data Processing Officer Centre for Behavioural Research in Cancer The Cancer Council Victoria http://www.cancervic.org.au/cbrchttps://webmail.accv.org.au/exchweb/bin/redir.asp?URL=http://www.cancervic.org.au/cbrc
On 2/26/07, epidata-list@lists.umanitoba.ca epidata-list@lists.umanitoba.ca wrote:
Hello everyone
I am after advice about the best way to record time and date information when collecting information about food poisoning
outbreaks,
given epidata does not have a time/date field. We want this
information
to estimate incubation periods, in order to get clues about the
likely
illness.
Incubation Incubation = time from when someone is exposed to the time they
become
unwell. For example someone may eat a buffet meal at 7pm on 21 February and become unwell at 1am on 22 February = incubation of 6 hours.
Current method At the moment we: a) enter information in two fields. OnsetDay is recorded in a date field, and onsettime in a numeric field (####) b) list the two fields (using epi info) to view the information c) calculate incubation manually.
Is there a better/easier way to do this? Also what is the
recommended
way for entering 24 clock time - should 7.30pm be 1930 or 19.30
thanks very much
Christine
Christine Roseveare Analyst Regional Public Health 570 9194 027 495 9671
-- The information contained in this email and any attachments is confidential and may be legally privileged. If you have received this message in error, please notify the sender immediately and remove all copies of the message, including any attachments. Any views or opinions expressed in this email (unless otherwise stated) may not represent those of Hutt Valley DHB. Thank you. ** Disclaimer added by HVDHB **
EpiData-list mailing list EpiData-list@lists.umanitoba.ca http://lists.umanitoba.ca/mailman/listinfo/epidata-list
Hi Christine,
I think I forgot to mention that for vhours to be a field it needs to be fairly large as the number of hours since 1899 is a big number. Also it needs to have two decimal places. I used a nine digit number plus two decimals when I tried it.
Once you know you have it working you could calculate the difference directly into the timediff field (which also needs two decimal places but does not need to be nearly as large) without having to store it in vhours1 and vhours2 first, to save having meaningless numbers lying about.
Also, I didn't use the word "LET" - not sure if this makes any difference. And the number will not calculate until all the fields in the formula are filled, i.e. if you put the code in the time field but do not yet have anything in the date field, it will not work. I put the full calculation in all fields so that any time a field was updated the difference would update also.
I will paste what I did below and hopefully it will clear anything else up I've forgotten to mention! Let me know how you go.
Thanks, Charity
Below is the text from the qes file I used to test my formulae.
vtime1 ##.## vdate1 <dd/mm/yyyy>
vhours1 #########.##
vtime2 ##.## vdate2 <dd/mm/yyyy>
vhours2 #########.##
timediff ####.##
And the code I used in my chk file (for the second time and date only, to save space):
vtime2 MUSTENTER AFTER ENTRY IF (vtime2 < 0) OR (vtime2 > 23.59) OR (Frac(vtime2) > 0.59) THEN HELP "Enter a valid time" GOTO vtime2 ENDIF vhours2=Int(vtime2) + (Frac(vtime2)/0.6) + (vdate2*24) vhours1=Int(vtime1) + (Frac(vtime1)/0.6) + (vdate1*24) timediff=vhours2-vhours1 END END
vdate2 MUSTENTER AFTER ENTRY vhours2=Int(vtime2) + (Frac(vtime2)/0.6) + (vdate2*24) vhours1=Int(vtime1) + (Frac(vtime1)/0.6) + (vdate1*24) timediff=vhours2-vhours1 END END
vhours2 NOENTER END Charity Jenkins Data Processing Officer Centre for Behavioural Research in Cancer The Cancer Council Victoria http://www.cancervic.org.au/cbrchttps://webmail.accv.org.au/exchweb/bin/redir.asp?URL=http://www.cancervic.org.au/cbrc
On 2/27/07, epidata-list@lists.umanitoba.ca <epidata-list@lists.umanitoba.ca
wrote:
Hi Charity
Thanks very much for your formula. Its sounds really good. I had a go at putting it in a check file. Following through your example below 'Diatime' is my 'vtime2' and 'diadate' is my vdate2. I thought I would start off slowly by seeing if I coudl calculate Vhours2. I created a new field called Vhours2 in my rec file and then I put the following code into the check file.
DIATIME AFTER ENTRY LET VHOURS2=INT(DIATIME)+(FRAC(DIATIME)/0.6)+(DIADATE*24) END END
Epi accepted the code but nothing appears in the vhours2 field when I enter information in the diadate and diatime fields. Can you see what I am doing wrong?
thanks
Christine Roseveare Analyst Regional Public Health 570 9194 027 495 9671
Dear Christine, Charity:
If you wish to keep the QES file uncluttered, keep just the 5 fields:
supperdate Date supper took place <dd/mm/yyyy> suppertime Time supper started ##.## onsetdate Date of symptom onset <dd/mm/yyyy> onsettime Time of symptom onset ##.## incubation Incubation period in hours ###.##
In the CHK file then make use of temporary variables:
BEFORE FILE define supperTemp ##########.## define onsetTemp ##########.## END
supperdate MUSTENTER END
suppertime MUSTENTER AFTER ENTRY supperTemp=(supperdate-"01/01/2000")*24+suppertime END END
onsetdate MUSTENTER END
onsettime MUSTENTER AFTER ENTRY onsetTemp=(onsetdate-"01/01/2000")*24+onsettime incubation=onsetTemp-supperTemp END END
incubation NOENTER END
Of course, you might wish to build in conditions as Charity suggests. Furthermore, you could make provisions for unknown exact times, etc, this is just one possible barebone approach if all is known.
The date "01/01/2000" is an arbitrary anchor date.
Regards,
Hans
epidata-list@lists.umanitoba.ca wrote:
......
Charity
Below is the text from the qes file I used to test my formulae.
......
On 2/27/07, epidata-list@lists.umanitoba.ca <epidata-list@lists.umanitoba.ca
wrote:
Hi Charity
Thanks very much for your formula. Its sounds really good. I had a go
thanks
Christine Roseveare
Hi Christine and Hans,
Christine - so glad to hear it worked for you!
Hans - that's a good idea about using an anchor date to help keep the temporary fields smaller, and also keeping them out of the qes file - I'll have to try that one.
Allowing for missing times and dates is a very good point too - it is always good to use a code for missing where possible, though in this case it may complicate the logic used in the chk file somewhat. Christine - do write again if you would like some help with this if you think you will allow a code for missing dates and times.
Regarding the anchor time - I was thinking that once Christine got the formulae working (as now she has) she could get rid of the temporary variables all together and instead use something like:
timediff= (Int(vtime2) + (Frac(vtime2)/0.6) + (vdate2*24)) - (Int(vtime1) + (Frac(vtime1)/0.6) + (vdate1*24))
in place of where we had:
vhours2=Int(vtime2) + (Frac(vtime2)/0.6) + (vdate2*24) vhours1=Int(vtime1) + (Frac(vtime1)/0.6) + (vdate1*24) timediff=vhours2-vhours1
So I think in this situation the anchor time would not still be needed?
Thanks, Charity
Charity Jenkins Data Processing Officer Centre for Behavioural Research in Cancer The Cancer Council Victoria http://www.cancervic.org.au/cbrc
I prefer the compact approach that Charity takes. Similarly, in a .chk file, the interval in hours is:
timediff = 24.0*(time2num(vtime2)-time2num(vtime1)+vdate2-vdate1)
assuming that vtime1, vtime2 are legal times as ##.## (hh.mm) and vdate1, vdate2 are date fields. The trick in a .chk file is catching the missing values and illegal values (times like 25.79, for example)
Jamie
participants (1)
-
epidata-list@lists.umanitoba.ca