SAS DATE

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,040
Accepted Solution

SAS DATE

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


Accepted Solutions
Solution
‎07-22-2015 10:56 AM
Trusted Advisor
Posts: 1,228

Re: SAS DATE

data have;

date='20FEB2014'd;

date_want=input(put(date,yymmddn8.),best.);

run;

View solution in original post


All Replies
Super User
Posts: 11,114

Re: SAS DATE

Couple ways:

funnydate= year(date)*10000 + month(date)*100 + day(date);

or

funnydate = input(put(date,yymmdd8.),best8.);

Super Contributor
Posts: 1,040

Re: SAS DATE

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

Solution
‎07-22-2015 10:56 AM
Trusted Advisor
Posts: 1,228

Re: SAS DATE

data have;

date='20FEB2014'd;

date_want=input(put(date,yymmddn8.),best.);

run;

Super Contributor
Posts: 1,040

Re: SAS DATE

Thanks Stat,

It works. What is the logic behind putting n8.  ????

Regards

Trusted Advisor
Posts: 1,228

Re: SAS DATE

Super User
Super User
Posts: 6,842

Re: SAS DATE

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.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 255 views
  • 6 likes
  • 4 in conversation