DATA Step, Macro, Functions and more

How to remove milliseconds from datetime26.6 format ?

Accepted Solution Solved
Reply
Contributor
Posts: 22
Accepted Solution

How to remove milliseconds from datetime26.6 format ?

I have a column in a sas dataset whose format and informat both are datetime26.6
I need only date and time with hh:mm:ss.
I tried reading date column using datetime26.6/anydtdte./anydtdtm. format but none works.

Does anyone have any idea how to read and convert the given column.


Accepted Solutions
Solution
‎07-04-2017 11:06 AM
Super User
Posts: 17,784

Re: How to remove milliseconds from datetime26.6 format ?

Milliseconds are stored as decimals, so round the value using the ROUND function. 

View solution in original post


All Replies
Contributor
Posts: 74

Re: How to remove milliseconds from datetime26.6 format ?

Pls share the sample data.

Contributor
Posts: 22

Re: How to remove milliseconds from datetime26.6 format ?

24APR2017:17:03:00.000000
22APR2017:15:02:39.000000
15APR2017:17:42:46.000000
10APR2017:20:05:31.000000
23APR2017:19:27:55.000000
02APR2017:19:07:03.000000
05APR2017:18:27:11.000000
18APR2017:16:13:20.000000
28APR2017:19:24:31.000000

 

I need only date and hh:mm:ss

Solution
‎07-04-2017 11:06 AM
Super User
Posts: 17,784

Re: How to remove milliseconds from datetime26.6 format ?

Milliseconds are stored as decimals, so round the value using the ROUND function. 

Contributor
Posts: 22

Re: How to remove milliseconds from datetime26.6 format ?

Thanks Reeza, Using Round function is working.

Super User
Posts: 17,784

Re: How to remove milliseconds from datetime26.6 format ?

@nikunjgattani marking your own answer as the solution is not correct unless you find and post the solution to your question. 

Contributor
Posts: 22

Re: How to remove milliseconds from datetime26.6 format ?

Sorry Reeza, I mistakenly marked my comment as a solution. I intended to mark your answer as a solution.
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 143 views
  • 1 like
  • 3 in conversation