Desktop productivity for business analysts and programmers

Re: Time periods in hour min sec

Reply
Super User
Posts: 11,134

Re: Time periods in hour min sec

this format may work for you

 

proc format library=work;

picture mytime

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

run;

Contributor
Posts: 66

Re: Time periods in hour min sec

Thank you . this would work for me.

Contributor
Posts: 66

Re: Time periods in hour min sec

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

Super User
Posts: 11,134

Re: Time periods in hour  min sec

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.

Contributor
Posts: 66

Re: Time periods in hour  min sec


               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

Contributor
Posts: 66

Re: Time periods in hour  min sec

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

Super User
Posts: 11,134

Re: Time periods in hour  min sec

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

Contributor
Posts: 66

Re: Time periods in hour  min sec

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?

Super User
Posts: 11,134

Re: Time periods in hour  min sec

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.

Contributor
Posts: 66

Re: Time periods in hour  min sec

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.

Ask a Question
Discussion stats
  • 9 replies
  • 319 views
  • 0 likes
  • 2 in conversation