BookmarkSubscribeRSS Feed
G_I_Jeff
Obsidian | Level 7
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:MM:SS 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)?
5 REPLIES 5
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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
G_I_Jeff
Obsidian | Level 7
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?
ArtC
Rhodochrosite | Level 12
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.
SASKiwi
PROC Star
Have you tried the MMSS. format that displays SAS times in minutes and seconds?
SPR
Quartz | Level 8 SPR
Quartz | Level 8
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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 5 replies
  • 1705 views
  • 0 likes
  • 5 in conversation