this format may work for you
proc format library=work;
picture mytime
low-high = '%Hhr:%Mmin:%Ssec' (datatype=time);
run;
Thank you . this would work for me.
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
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.
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
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
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
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?
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.
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.
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!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.