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

Hi,

 

I have a large dataset where the dates are in format '$27' and displayed like '

2018-09-01 14:21:51:333 GMT

'. I need to convert this to datetime13 or datetime18. What would be the best way to do this?

 

Thanks in advance for any help given!

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

data want;
have='2018-09-01 14:21:51:333 GMT';
want=input(have,  ymddttm19.);
format want datetime20.;
run;

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20

data want;
have='2018-09-01 14:21:51:333 GMT';
want=input(have,  ymddttm19.);
format want datetime20.;
run;
JackoNewbie
Calcite | Level 5

This worked 😄

Thanks!

andreas_lds
Jade | Level 19

@JackoNewbie wrote:

Hi,

 

I have a large dataset where the dates are in format '$27' and displayed like '

2018-09-01 14:21:51:333 GMT

'. I need to convert this to datetime13 or datetime18. What would be the best way to do this?

 

Thanks in advance for any help given!


If you can, fix the creation of that datasets, so that a proper datetime-variable is created. There is hardly any good reason for storing datetimes as strings at all.

Tom
Super User Tom
Super User

Do you really have datatime values with different time zones than GMT? 

If so do you need the values adjusted so that they are synchronized to a single time zone?

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1185 views
  • 0 likes
  • 4 in conversation