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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 1451 views
  • 0 likes
  • 4 in conversation