Hi,
I have a date variable with date9. format: 20FEB2014
I need to convert it to a number 20140220 and not a date.
Any comments highly appreciated
Regards
data have;
date='20FEB2014'd;
date_want=input(put(date,yymmddn8.),best.);
run;
Couple ways:
funnydate= year(date)*10000 + month(date)*100 + day(date);
or
funnydate = input(put(date,yymmdd8.),best8.);
Hi Ballard,
Thanks for the reply.
It would throw me an error as shown below.
The dater I have there is 20FEB2014. It's numeric and date9 format.
NOTE: Invalid argument to function INPUT at line 42 column 13.
Regards
data have;
date='20FEB2014'd;
date_want=input(put(date,yymmddn8.),best.);
run;
Thanks Stat,
It works. What is the logic behind putting n8. ????
Regards
Please see below for more detail.
The YYMMDDN format is for displaying dates in ymd format without any separator character. Using a length of 8 will force it to use 4 digits for the year.
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.