BookmarkSubscribeRSS Feed
ebonyw
Calcite | Level 5

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 StartDate/Time EndMissing Time (New Variable)
9/27/13 9:159/28/13 12:00 ------
9/28/13 12:159/28/13 13:15Time from the end of their recording time to when they started recording again...14 minutes the provider didn't record
9/29/13 15:159/30/13 11:3026 hours the provider did not record temperatures
10 REPLIES 10
Reeza
Super User

Are the first two columns what your data looks like or does your colour coding indicate something about the data?

ebonyw
Calcite | Level 5

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. 🙂

Reeza
Super User

The duration for the second record is 1 hour. Where does 14 minutes come from?

ebonyw
Calcite | Level 5

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!

PaigeMiller
Diamond | Level 26

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)

data abc;

    set have;

    prev_end_time=lag(end_time);

    missing_time=start_time - prev_end_time;

    format missing_time time.;

run;

--
Paige Miller
ebonyw
Calcite | Level 5

THANK YOU SOOOOO much, Paige. Yes...you understood my lengthy explanation correctly. 🙂 I'm going to try this now. Thank you!!!!!

Reeza
Super User

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.

data have;

informat time_start time_end datetime20.;

format time_: datetime21.;

input time_start time_end;

cards;

27SEP13:09:15:00 28SEP13:12:00:00

28SEP13:12:15:00 28SEP13:13:15:00

29SEP13:15:15:00 30SEP13:11:30:00

;

run;

data want;

set have;

time_unplugged=time_start-lag(time_end);

format time_unplugged hhmm7.;

run;

proc print data=want;

run;


ebonyw
Calcite | Level 5

Thank you so much, Reeza!!!!

PaigeMiller
Diamond | Level 26

How is this different than your other thread?

https://communities.sas.com/thread/71757

How could anyone or anything determine "missing time" from the information provided?

--
Paige Miller
ebonyw
Calcite | Level 5

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 1316 views
  • 7 likes
  • 3 in conversation