Help using Base SAS procedures

Adding clock times??

Reply
Frequent Contributor
Posts: 75

Adding clock times??

Sorry if this has been posted, but I've searched through the forums and didn't find my answer.
I need to add thousands of clock time values together and represent the sum in minutes (example):

12:24:13
14:33:01
29:01:44
00:13:59
100:51:19
9124:16

I'm new to SAS and am accumulating total clock time values together per customer. The input is already coming in a SAS TIME format. When I summarize all the times, I am getting an HHH:MMSmiley FrustratedS result. I realize it would be easy to multiply the summary hours by 60 and add to the minutes but I also need to represent other entries that are not summarized.

So out of curiosity, is there a way to format summarized values in minutes? Or is there a way to converted stored, formatted times back to SAS times (stored in seconds from midnight)?
Super Contributor
Super Contributor
Posts: 3,174

Re: Adding clock times??

SAS TIME variables are numeric type variables representing "seconds" -- the decision on how the data values is displayed is determined using the FORMAT statement (or ATTRIB FORMAT= parameter).

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

using dates and times site:sas.com
Frequent Contributor
Posts: 75

Re: Adding clock times??

I understand that SAS TIME variables are numeric values representing seconds from midnight, but when I perform a proc print from the data I am summarizing (before I do anything with it), it is printing the times in TIME8. format without me coding a FORMAT on my print. How can I get the times back to the SAS (default) numeric value, or represent my total in minutes?
Valued Guide
Posts: 634

Re: Adding clock times??

If PRINT displays the value using TIME8. format without you specifying the format, then the format has already been attached to the variable. Format assignments are usually inherited from earlier steps.

PROC CONTENTS will show the format assignments for the variables in your data set.

Formats do not alter what is stored only how the value is to be displayed.
Super User
Posts: 3,260

Re: Adding clock times??

Have you tried the MMSS. format that displays SAS times in minutes and seconds?
Super Contributor
Super Contributor
Posts: 365

Re: Adding clock times??

Hello G.I.Jeff,

It could be solved by this way, for example,
[pre]
data t;
input time time10. ;
format time time10.;
datalines;
12:24:13
14:33:01
29:01:44
00:13:59
100:51:19
;
run;
proc SQL;
create table r as
select ROUND(sum(time)/60) as r
from t
;quit;
[/pre]
Sincerely,
SPR
Ask a Question
Discussion stats
  • 5 replies
  • 157 views
  • 0 likes
  • 5 in conversation