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

Hi -

Please forgive this newbie question.  I have looked online extensively and have not been able to solve it. 

I have a variable, 'time', that contains timestamps that look like this:

0:00:01

0:00:16

15:53:46

This variable is currently in character format ($8).  I have tried the recommended tricks to convert it to numeric. Here are some examples of what I have tried: 

data file1; set file;

infile ".........";

input time $8;

fmttime=input(time,8.);

run;

data file1; set file;

fmttime=time * 1;

run;

data file1; set file;

fmttime=put(time,12.);

run;

None of these are working. How would others go about doing this conversion?

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Try

fmttime = input(time, time8.);

This will create a time value that can be manipulated with the time functions such as INTNX or INTCK and a format of time8. would display as a time value.

Your attempts failed because the f8. format can't handle :

the multiple failed because it can't handle : either.

View solution in original post

1 REPLY 1
ballardw
Super User

Try

fmttime = input(time, time8.);

This will create a time value that can be manipulated with the time functions such as INTNX or INTCK and a format of time8. would display as a time value.

Your attempts failed because the f8. format can't handle :

the multiple failed because it can't handle : either.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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