BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I am trying to input a time value that is given in 00:00:00 (Hour:Minute:Second) Format. I am wondering how I can input this so SAS converts it to all seconds so I can subtract and add the times to eachother. I then need to convert it back to the Hour:Minute:Second time format. Anyone know the imput function command or how I could do this? I am pulling the data from a .csv file. Thanks for any help.
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
You can use the SAS INPUT function in a DATA step to convert a text-string in the format you mentioned in your post to a SAS numeric variable. When converted, the value will represent seconds, and so then you choose a SAS FORMAT to display your data as needed.

The SAS support website http://support.sas.com/ and its SEARCH facility can provide both documentation and supplemental technical conference topic material.

Scott Barry
SBBWorks, Inc.
deleted_user
Not applicable
Think you need the hhmmss format, which convert the data on which you can perform calculations.

data test;
input time hhmmss8.;
time_5 = time + 5*60;
format time time_5 tod.;
cards;
02:32:41
;
run;

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
  • 2 replies
  • 610 views
  • 0 likes
  • 2 in conversation