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

Hi all,

 

  My time of arrivals were in excel as '17:07' and there must have previously been some character code in the column, because when I imported to SAS it changed to $21. and looks like '.7139444444444' except it's now in character. Any ideas how to change it back to the original numeric 24-hr time? 

 

Data have;

arrival time

.73194444444

.14652777778

.34444444444

.3

data want;

arrival time

17:07

3:31

8:16

7:12

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Excel stores time as fraction of a day. So just multiple by 24 hours.

data have;
  input arrival $20.;
cards;
.73194444444
.14652777778
.34444444444
.3
;

data want;
  set have;
  time = '24:00't * input(arrival,32.);
  format time tod5.;
run;

Results:

Obs    arrival          time

 1     .73194444444    17:34
 2     .14652777778    03:31
 3     .34444444444    08:16
 4     .3              07:12

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

Excel stores time as fraction of a day. So just multiple by 24 hours.

data have;
  input arrival $20.;
cards;
.73194444444
.14652777778
.34444444444
.3
;

data want;
  set have;
  time = '24:00't * input(arrival,32.);
  format time tod5.;
run;

Results:

Obs    arrival          time

 1     .73194444444    17:34
 2     .14652777778    03:31
 3     .34444444444    08:16
 4     .3              07:12

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 324 views
  • 3 likes
  • 2 in conversation