BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DME790
Pyrite | Level 9

I have data source that has 15 minute intervals which I would like to group by hour.

 

If I use the format EVENT_TM hour.; format it sums the 8:30 and 8:45 to the 9am calculation.

 

Data Work.Interval_Final;

Set Work.Final_Int;

format EVENT_TM hour.;

Run;

 

 

How do I get the time inetrvals to add :00 :15 :30 and :45 to the correct hour.

 

Sample data below (Apologies I can't convert the data to the right format for others to use)

 

EVENT_DTEVENT_TMCALLS_ANSWERED_CNTCALLS_ABANDONED_CNTTOTAL_ANSWER_TM
11/01/20178:00:00937144734966
11/01/20178:15:00425158639406
11/01/20178:30:00402110627846
11/01/20178:45:00363121516766
11/01/20179:00:00407100613785
11/01/20179:15:00456112629621
11/01/20179:30:00503129671057
11/01/20179:45:00472119608942
11/01/201710:00:00485136702004
11/01/201710:15:00510132747481
11/01/201710:30:00361134438537
11/01/201710:45:0035694451957
11/01/201711:00:00457121603397
11/01/201711:15:00592169885680
11/01/201711:30:00416117549181
11/01/201711:45:00409132569009
11/01/201712:00:00447128630113
11/01/201712:15:00485171733852
11/01/201712:30:00405118549902
11/01/201712:45:0032092

372392

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Try the TIME2. format instead.

 

If you want it displayed as 8:00 you'll likely need either a custom format or to do a calculate and create a new variable to work with. 

View solution in original post

2 REPLIES 2
Reeza
Super User

Try the TIME2. format instead.

 

If you want it displayed as 8:00 you'll likely need either a custom format or to do a calculate and create a new variable to work with. 

ballardw
Super User

If you have a SAS data set these instructions will allow you to create the code for a data step to replicate your data (or a subset for example) https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

 

Is your sample data what you have or what you want? It looks like the time is already as you requested so we would need to see how it starts.

 

You need to include what you want as an output as it is not clear what you are doing. You say "sums the 8:30 and 8:45 to the 9am calculation" but that would only happen if you sent the data to a proc like means, report or tabulate.

 

Do you have data at shorter intervals and you need to group it?

Maybe something like this:

data have;
   informat time time.;
   format time time.;
   input time;
   newtime = intnx('minute15',time,0,'B');
   format newtime time.;
datalines;
08:10:15
08:14:00
08:20:21
08:29:59
;
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2697 views
  • 0 likes
  • 3 in conversation