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

Hi Guys, 

 

I have "2018-10-01 00:00:00:00" as char value and I want to convert it into sas datetime value through proc sql .. please help me out.

 

Thanks, 

Arun 

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

please try the anydtdtm format

 

data have;
x='2018-10-01 00:00:00:00';
y=input(x,anydtdtm.);
format y datetime20.;
run;
Thanks,
Jag

View solution in original post

3 REPLIES 3
novinosrin
Tourmaline | Level 20

Hello @Arun_shSAS 

 

Will this help?

 

proc sql;
select *,input(char,ymddttm19.) as sas_datetime format=datetime20.
from your_input;
quit;

This assumes you have a char datetime variable in your input dataset

Arun_shSAS
Fluorite | Level 6

proc sql;
select *,input(my_time,anydtdtm.) as sas_datetime format=datetime20.
from temp;
quit;

Jagadishkatam
Amethyst | Level 16

please try the anydtdtm format

 

data have;
x='2018-10-01 00:00:00:00';
y=input(x,anydtdtm.);
format y datetime20.;
run;
Thanks,
Jag

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 31373 views
  • 1 like
  • 3 in conversation