Change Numeric to date format SAS

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

Change Numeric to date format SAS

I have a date column that comes in like 20,150,818.00 and I need to change it to date format to appear as 20150818 or yyyymmdd .. I have tried many variations that have not work, one being below

 

IntDate = INPUT(PUT(IntDate,10.),YYYYMMDD8.);
  FORMAT IntDate date8.;
Run;


Accepted Solutions
Solution
‎03-11-2016 06:22 PM
Super User
Posts: 5,085

Re: Change Numeric to date format SAS

One that should work:

 

data want;

set have;

IntDate = input(put(IntDate, 8.), yymmdd8.);

format IntDate yymmdd8.;

run;

 

Note that a format of yymmdd10 would also be possible (as would any other date format).

View solution in original post


All Replies
Super User
Posts: 17,840

Re: Change Numeric to date format SAS

Why does your initial PUT have a length of 10? Does it turn out the way you expect using 10?

New Contributor
Posts: 2

Re: Change Numeric to date format SAS

No and that's just one variation I tried
Solution
‎03-11-2016 06:22 PM
Super User
Posts: 5,085

Re: Change Numeric to date format SAS

One that should work:

 

data want;

set have;

IntDate = input(put(IntDate, 8.), yymmdd8.);

format IntDate yymmdd8.;

run;

 

Note that a format of yymmdd10 would also be possible (as would any other date format).

Super User
Posts: 10,500

Re: Change Numeric to date format SAS

I would also investigate how a date apparently acquired a currency(?) format to begin with. The earlier in a data process the data is "corrected" the better all around. If you are going to repeat the process repeatedly then you may save yourself a lot of work by preventing such things in the first place.

☑ This topic is SOLVED.

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

Discussion stats
  • 4 replies
  • 352 views
  • 0 likes
  • 4 in conversation