BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
robulon
Quartz | Level 8

Hi,

 

I'm a bit stuck here and haven't been able to track a solution down so hoping for a bit of assistance.

 

I have written some sas code that uses proc sql to sum up telephone call times and produces a total number of hours, minutes and seconds that a team has completed each day. I have applied the time. format so get, for example, for one day I get a total of 40:34:15 which is great.

 

The problem comes when I look to export the report to Excel for distribution. Excel seems to be automatically applying a time of day format, so for the above example, it is displaying 16:34:15.

 

Can anyone suggest a way around this? Ideally I just want to be able to run the code and be in a position to send out the excel report.

 

Many thanks,

Rob  

1 ACCEPTED SOLUTION

Accepted Solutions
robulon
Quartz | Level 8

I've managed to sort this, I've used put to create the time variables as character and they are exporting into the Excel sheet as required: -

 

put(round(sum(talk),1),time.) as total_time

View solution in original post

6 REPLIES 6
robulon
Quartz | Level 8

I've managed to sort this, I've used put to create the time variables as character and they are exporting into the Excel sheet as required: -

 

put(round(sum(talk),1),time.) as total_time

robulon
Quartz | Level 8
Not sure if it's forum etiquette to mark your own solution but there you go
Kurt_Bremser
Super User

@robulon wrote:
Not sure if it's forum etiquette to mark your own solution but there you go

That's OK, as it points any other who views the thread to something that worked. And it was you who found a viable solution.

robulon
Quartz | Level 8

Hi Kurt,

 

I am writing to a named range in the Excel sheet. When I opened the Excel sheet the data in the cell just showed as 16:34:15, however if I typed in the 40:34:15 and applied the [h]:mm:ss format, it showed the correct figure, so the issue seemed to be in how Excel was interpreting the data I was trying to write into it. 

Patrick
Opal | Level 21

@robulon  Styles let you change the format Excel uses.

data sample;
  format hours time.;
  do hours='11:00't to '28:00't by 2999;
    output;
  end;
  stop;
run;

options missing=' ';
ods listing close;
ods excel file='~/test/sample.xlsx';
proc print data=sample noobs;
  var hours / style(column)={tagattr='format: [h]:mm:ss'};
run;
ods excel close;
ods listing;

Patrick_0-1585132563763.png

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 6 replies
  • 855 views
  • 2 likes
  • 3 in conversation