Hello,
I have 4-Aug-2016 ($20.) , 05-Aug-2016 ($20.) and I want to convert it into a proper date foramt. The following does not work. Could someone suggest a proper method to do it?
data want;
set have;
Date2= input(Date,worddate.);
format Date2 date10.;
run;
Thanks
One example:
data have; length dt $20; dt="4-Aug-2016"; output; dt="05-aug-2016"; output; run; data want; set have; d2=input(compress(dt," -"),date9.); format d2 date9.; run;
One example:
data have; length dt $20; dt="4-Aug-2016"; output; dt="05-aug-2016"; output; run; data want; set have; d2=input(compress(dt," -"),date9.); format d2 date9.; run;
Typo, its not needed.
The answer is already solved, just wanted to mention, that the date11 informat can read the dates that are shown.
See sample code below:
data have;
length dt $20;
dt="4-Aug-2016"; output;
dt="05-aug-2016"; output;
run;
data want;
set have;
d2 = input(dt, date11.);
format d2 date9.;
run;
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.