DATA Step, Macro, Functions and more

Time function

Reply
N/A
Posts: 0

Time function

I am trying to input a time value that is given in 00:00:00 (Hour:MinuteSmiley Frustratedecond) 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:MinuteSmiley Frustratedecond 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.
Super Contributor
Super Contributor
Posts: 3,174

Re: Time function

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.
N/A
Posts: 0

Re: Time function

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;
Ask a Question
Discussion stats
  • 2 replies
  • 134 views
  • 0 likes
  • 2 in conversation