BookmarkSubscribeRSS Feed
ballardw
Super User

this format may work for you

 

proc format library=work;

picture mytime

low-high = '%Hhr:%Mmin:%Ssec' (datatype=time);

run;

9 REPLIES 9
avatar
Fluorite | Level 6

Thank you . this would work for me.

avatar
Fluorite | Level 6

How do I present in min: sec  the following

I need to read call duration in minutes and sec  and display the sum  appropriately as hour:min:sec.

for example 1:50 + 20:15 + 7.25 ---   = 195.59

sum should display like 3hr: min:sec etc

Please give your suggestions

Thanks

ballardw
Super User

Provide an example of what your actual data that you need to read looks like is the first step. It is likely to involve reading with a TIME format.

avatar
Fluorite | Level 6


               I used Time5.2 to read call_duration ( data collected as minutes and seconds)

               I did use sum(call_duration) in proc_sql  to get the total duration format=Time6.2  (eg: 195.59) . I would like to display sum column  as    Hr:mim:sec

56449122   1:50 195:59

56449122  20:15 195:59

56449122  7:25 195:59

56449122  20:06 195:59

56449122  20:20 195:59

56449122  13:46 195:59

56449122  13:29 195:59

56449122  12:50 195:59

56449122  37:31 195:59

56449122  1:58 195:59

56449122  11:18 195:59

56449122  35:11 195:59

56449405  18:50 18:50

56449405  0 18:50

56549659  0 41:51

56549659  10:06 41:51

56549659  3:20 41:51

56549659  0 41:51

56549659  0 41:51

56549659 16:20 41:51

56549659  12:05 41:51

avatar
Fluorite | Level 6

just  want to give more details ----

the first column is Record_id,. second column is call_duration and the third column sum_of_call_duration

I am summing call duration by Record_id.

Hope this helps.

thanks

ballardw
Super User

You should be able to assign a format to the sum_of_call_duration variable, time10. should work or if you want the words then the Mytime. format at the start.

Easiest may be to add the format in the SQL code

avatar
Fluorite | Level 6

I tried what you have suggested. for some reason it applies the format not convert minutes to hours etc

In the above example the sum_call_duration 195:59 appears as 195:59:00 instead of 3hrs:10min:59sec

may be I have to use some time functions?

ballardw
Super User

More likely the difficulty arises with how you read the data. Post the code and some rows of data to read.

The fact that you were showing 195:59 for the sum of your times makes me suspect something is getting turned into strings or an incorrect format/informat is applied somewhere along the line.

avatar
Fluorite | Level 6

You are absolutely right. I just realised the call_duration is a calculated column in Access database. I have imported that table to use for my reporting . I will check with the db owner for details and try using the original column instead.

Thanks for all your input.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 9 replies
  • 2370 views
  • 0 likes
  • 2 in conversation