Help using Base SAS procedures

Convert numeric in format YY to date

Posts: 1

Convert numeric in format YY to date

 Hey there,


I need to convert a numeric in the format YY (e.g. '70' represents '1970') to a date format. I don't think I can use informats since I'm reading this in from a xls file.  Is there a straightforward way to do this? Whenever I try to use date formats, SAS assumes the values are already in SAS dat format and outputs 1960 for them all, because the values are all so small. I know this is a very basic question, but I'm brand new to SAS and after searching the internet I couldn't seem to find a suitable answer. Any help will be greatly appreciated.




Super Contributor
Posts: 490

Re: Convert numeric in format YY to date

data test;
input yy;
format sasdate year.;
Super User
Posts: 5,082

Re: Convert numeric in format YY to date

I can't really think of a good reason to convert 60 to a date.  Why not just convert it to a year?  


Y = Y + 1900;


Easy to code, simple to interpret later.  


As was noted in the other response, if you do want to convert it to a date, you will have to pick which day of the year to use.  

Super User
Super User
Posts: 7,401

Re: Convert numeric in format YY to date

I completely agree with @Astounding, why bother converting when your just adding a number on.  However I would also add why are you using partial dates?  Should 10 be 1910 or 2010?  I would start by going back to the source and fixing the data there, you should never be guessing on what the data represents.

Respected Advisor
Posts: 3,777

Re: Convert numeric in format YY to date

Also search at  You will find the answer to most questions in the online documentation.


I do not agree that converting the year to a SAS date is a bad idea.  There are many reasons to use SAS dates that should be obvious to most.


@mohamed_zaki has answered your question and provide the formated needed to display '01JAN1970'd as a year.

Ask a Question
Discussion stats
  • 4 replies
  • 5 in conversation