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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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