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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.