02-24-2015 11:22 AM
I have data from medical providers that documents the time they recorded temperatures in their vaccine storage units. They are supposed to record temps 24 hrs a day to make sure their refrigerators and freezers maintain appropriate temps so vaccines are not compromised. I know things happen where they may forget to plug their digital thermometers back after reading recordings or maybe have power failures...so they have a little leeway so 24 hours or more of missing recording time not good.
What would be the syntax to determine how much time is missing between a provider's storage unit record times?
|Date/Time Start||Date/Time End||Missing Time (New Variable)|
|9/27/13 9:15||9/28/13 12:00||------|
|9/28/13 12:15||9/28/13 13:15||Time from the end of their recording time to when they started recording again...14 minutes the provider didn't record|
|9/29/13 15:15||9/30/13 11:30||26 hours the provider did not record temperatures|
02-24-2015 11:30 AM
Sorry, Reeza. I was just trying to make it clear what was being used to calculate the missing time. The coloring truly doesn't mean anything. Sorry for the confusion. :-)
02-24-2015 01:23 PM
Reeza - The 14 minutes is the difference in time from the 1st line's ending and the 2nd line's start time. This doctor unplugged his thermometer/ended recording at 12:00 on 9/28/13 (END time for the first line). He started recording again at 12:15 on 9/28/13 (second line's START time). There was 14 minutes that he did have temperature data because his thermometer was not recording. Hope that makes sense. Thanks so much for your thoughts. I feel like pulling my hair out. Ahhh!
02-24-2015 01:38 PM
Ok, I get it, so you want to subtract the end time on line 1 from the start time on line 2.
Same method works as in the other thread, once you have taken care of the issue that the data isn't on the same line.
Try something like this (assuming these are actual datetime values)
missing_time=start_time - prev_end_time;
format missing_time time.;
02-24-2015 01:48 PM
Use the lag function, see the code below. Then use if/then calculations based on that variable.
Please note that the duration from 00 to 15 is 15 minutes, if you need 14 minutes as you've indicated you'll need to use a correction factor.
If your variables are SAS Datetime variables, time_unplugged, will be noted in seconds and you'll need to convert that to minutes/hours as required or use the hhmm format applied. Otherwise, as indicated in your other questions you'll need to convert it to a SAS datetime.
informat time_start time_end datetime20.;
format time_: datetime21.;
input time_start time_end;
format time_unplugged hhmm7.;
proc print data=want;
02-24-2015 01:09 PM
How is this different than your other thread?
How could anyone or anything determine "missing time" from the information provided?
02-24-2015 01:18 PM
Hi Paige - these are two seperate questions. The first one that you helped me on, I needed to calculate total record time (duration) from the start/end times provided. This question, however, is asking how to figure out the time in between each recording. So, for example, the first line shows the doctor measure temps for a little over 26 hours. He unplugged his digital thermometer and didn't hook it back up until 12:15 on 9/28/13 (the second line)....14 minutes later (stopped recording at 12:00, began recording again at 12:15...14 minutes that are not accounted for). I can't figure out what SAS code to use that will calculate the missing time from one line to the next. Hope that makes sense! :-( From your comment above, if there isn't a way to determine missing time from the information provided, then that is good to know, as well.