i have date value like 15may2012 i want convert this date to 15may2012:00:00:00 how it will come?
Hi,
Try this..
data one;
yy=dhms('31MAy2012'd,00,00,00);
format yy datetime.;
run;
Thanks,
Shiva
Thank u for u r answer
But you used 15may2012'00'00'00 .but my doubt is only use 15may2012 in input value(informat).and get the value like 15may2012:00:00:00 as format
please be help..
Hi Rahul,
you can also try this...but I will use DHMS function like above to get the datetime format.
data one;
xx='31MAy2012'd;
yy=xx*86400;
format yy datetime.;
run;
If you directly apply format on xx as datetime. then you will different values like 01JAN60:05:19:04
Thanks,
Shiva
If you are reading the value from a text file then use the ANYDTDTM informat.
data _null_;
input @1 date date9. @1 dt anydtdtm. ;
format date date9. dt datetime.;
put (_all_) (=);
cards;
15MAY2012
run;
date=15MAY2012 dt=15MAY12:00:00:00
İf you already have a date value, 15May2012, stored in a data set but you want to display datetime,15May2012:00:00:00, without changing the value of underlyıng variable you may try picture directives in proc format.
Zafer
proc format;
pıcture dtfmt low-high = '%d%b%Y:00:00:00' (datatype=date);
run;
data _null_;
x = '15May2012'd;
put x dtfmt18.;
run;
15MAY2012:00:00:00
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 how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.