hi guys,
Can anyone please tell me what i am doing wrong here
data test;
date='02oct2014'd;
format date datetime18.;
run;
the date in the output is 1/1/1960 5:33:18 AM
Thanks
You are trying to write a date (number of days) using a datetime format. So it is interpreting the number of days as the number of seconds.
You are trying to write a date (number of days) using a datetime format. So it is interpreting the number of days as the number of seconds.
In order to get it in datetime format, try something like this
data test;
date='02oct2014'd;
new_date=date*86400;
format date date9. new_date datetime18.;
run;
thank you both
so i actually used new_date=dhms(date,00,00,00) and then applied the format datetime.
You could also just write a datetime literal instead of a date literal.
datetime='02oct2014:00:00'dt;
I know but the thing is this date variable is actually a macro var from another SAS code which resolves to 02oct2014 so I had to use the "&date"d in the dhms function
Using Tom's method you could specify "&date.:00:00:00"dt to resolve your SAS date as a datetime.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.