My data is imported from a csv file. In the csv file, I have a date field showing dates in the format, 22/05/39. When I click on the cell I can see that the date is in reference to the year 2039 but when I import it to SAS, it shows as 1939.
Can anyone help me with a way around this please?
Thanks.
You can modify the yearcutoff= system option, but that is only a stopgap measure for data that you have no control over. 4-digit years are the way to go.
Use a 4-digit format for the year in Excel. Period.
2-digit years should have been permanently disallowed since 2000.
Thanks, I agree! I can get around it like that but was hoping there was an alternative solution so that I didn't have to reformat the data every month.
You can modify the yearcutoff= system option, but that is only a stopgap measure for data that you have no control over. 4-digit years are the way to go.
On your import program (which you haven't shown us so I can only guess), in the datastep have a line:
date=intnx('year',date,100);
This will move the date's year on 100. You will have to fix yourself or alter system options as the data is "bad".
Thanks but I can't do this as my data spans more than 100 years. I think the only option is to format the data in Excel to show 4 digits as per KurtBremser response.
I hope that you have the correct values. If the file is csv and then opened in Excel and formatting applied sometimes values get "interpretted" by Excel in ways that may not quite be as desired.
Note that Excel is likely using a similar approach to the YEARCUTOFF so be careful about saving over your original file.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.