02-22-2016 07:02 PM
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.
02-22-2016 08:08 PM
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.
02-23-2016 04:45 AM
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.
02-23-2016 10:37 AM
Also search at support.sas.com. 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.