i have 2 columns,
var/value/type
month = feb <-- char
day=1 <-- num
i want to convert them into date format like,
var=date
value= 1 Feb 2017 or 02/01/2017
can someone please help...Thank you...
Do you want a character value:
length datechar $ 11.; /* this assumes that month will only ever be 3 characters, it will need to be longer if that is not the case*/
datechar = catx(' ',day,month,'2017'); or possibly catx(' ',day,propcase(month),'2017') depending on how you want capitalization of the month.
or a SAS date value? (if your month is longer than 3 characters or a non-standard abbreviation then extra logic will be needed*/
date = input(catt(day,month,'2017'),date9.);
format date date9.;
If you don't have a year value then you need to provide one explicitly.
Do you want a character value:
length datechar $ 11.; /* this assumes that month will only ever be 3 characters, it will need to be longer if that is not the case*/
datechar = catx(' ',day,month,'2017'); or possibly catx(' ',day,propcase(month),'2017') depending on how you want capitalization of the month.
or a SAS date value? (if your month is longer than 3 characters or a non-standard abbreviation then extra logic will be needed*/
date = input(catt(day,month,'2017'),date9.);
format date date9.;
If you don't have a year value then you need to provide one explicitly.
When building nested functions, testing one at a time.
Your parenthesis is in the wrong location, you're trying to concatenate all values include Date9.
Try moving the parenthesis to after 2017.
You probably want a format applied as well, to display it the way you want
I corrected the code in my post for the SAS date, I didn't see that my first) hadn't been typed.
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.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.