Hi,
I have a character variable that has a date string in it, so its not a real date variable but I need to change it to one. The values look like this.
Apr-01-2015
Apr-05-2015
Mar-05-2015
May-10-2015
I have been trying various of syntax and functions but I haven't been able to figure-out the right combination. This is what I have so far:
order_date_new2= input(compress(order_date,'-'), yymmdd8.);
Any help is appreciated!
Hi,
The syntax that you have use is almost OK. The format yymmdd, as far as I know, need First the year, then month and last Day, if you have dates in that format, I'm sure that is better ways to do it, but I will use Date9
date_real=input(scan(order_date,2,'-')||scan(order_date,1,'-')||scan(order_date,3,'-'),date9.);
Hi,
The syntax that you have use is almost OK. The format yymmdd, as far as I know, need First the year, then month and last Day, if you have dates in that format, I'm sure that is better ways to do it, but I will use Date9
date_real=input(scan(order_date,2,'-')||scan(order_date,1,'-')||scan(order_date,3,'-'),date9.);
Perfect. Thanks!
There is an INFORMAT that will work too. Remember to RTM.
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.