DATA Step, Macro, Functions and more

Time format in SAS

Accepted Solution Solved
Reply
Occasional Learner AY2
Occasional Learner
Posts: 1
Accepted Solution

Time format in SAS

[ Edited ]

 

Hi,

I have different values of time in the format MMSmiley FrustratedS. I am trying to figure out how to convert the values for time I have to numeric decimal. So for example, a time of 6:30 should be converted to 6.5.

Thanks in advance.

 

 


Accepted Solutions
Solution
‎12-11-2015 12:00 AM
Super User
Posts: 19,770

Re: Time format in SAS

Use the minute and second function to get the individual components and add them together. Time is stored as seconds so you can't straight apply a format.

View solution in original post


All Replies
Solution
‎12-11-2015 12:00 AM
Super User
Posts: 19,770

Re: Time format in SAS

Use the minute and second function to get the individual components and add them together. Time is stored as seconds so you can't straight apply a format.

Respected Advisor
Posts: 4,919

Re: Time format in SAS

You can convert time values into number of hours by dividing time by the duration of an hour:

 

hours = time / '01:00:00't;

 

PG
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 176 views
  • 0 likes
  • 3 in conversation