BookmarkSubscribeRSS Feed
Calcite | Level 5

 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.




Barite | Level 11
data test;
input yy;
format sasdate year.;
Opal | Level 21

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.  

Diamond | Level 26 RW9
Diamond | Level 26

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.

Jade | Level 19

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.



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 5 in conversation