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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: