BookmarkSubscribeRSS Feed
ari
Quartz | Level 8 ari
Quartz | Level 8

Hi ,

 

Is there an easy way to convert  time values in time5. format into nominal time values.?

Example: 8:30 as 8.5

                16:30 as 16.5

                17:45 as 17.75

 

 

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

One way:

data want;
  time="08:30"t;
  number=hour(time)+ ((10 / (60/minute(time)))/10);
  output;
  time="17:45"t;
  number=hour(time)+ ((10 / (60/minute(time)))/10);
  output;  
  format time time5.;
run;
Kurt_Bremser
Super User

Since time values are just counts of seconds, a simple division and rounding will do it:

data test;
input time time5.;
time_nom = round(time/3600,.01);
format
  time time5.
  time_nom 5.2
;
cards;
08:30
16:30
17:45
;
run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 5923 views
  • 2 likes
  • 3 in conversation