Hi,
I have a variable called "Date" which is currently in a CHAR format $15 and the dates are displayed as Jan-18, Feb-18 etc.
How do I change this to show a date format, ideally to keep the same format if possible like Jan-18, Feb-18.
I have tried this but the new variable just shows a '.'
input(date, yymmn6.) as newdate,
Missed a dot:
data have; date='Jan-18'; run; proc sql; create table want as select input(cats('01',compress(date,"-")),date7.) as newdate format=monyy6. from have; quit;
Please note above how simple it is to provide test data, and show code you are using, it saves us guessing.
A date has to have all three components, even if you decide to format it to show less than that. So you need to append a default day value:
input(cats('01',compress(date,"-")),date7.) as newdate format=monyy6,
Missed a dot:
data have; date='Jan-18'; run; proc sql; create table want as select input(cats('01',compress(date,"-")),date7.) as newdate format=monyy6. from have; quit;
Please note above how simple it is to provide test data, and show code you are using, it saves us guessing.
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.