BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
AMFR
Quartz | Level 8

I have a 3 numeric datetime columns with the format DateTime. When I export the SAS data into EXCEL the year of the column for 2026 is showing as 1926. How can i fix this? What I am doing wrong. Thanks in advance

1/1/2026 12:54 is showing up in EXCEL as 1/1/1926 12:54

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

Check your YEARCUTOFF setting -- it might be set to 1926. 
See: YEARCUTOFF option setting for SAS Viya 3.5 and older SAS 9.4 releases 

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

View solution in original post

9 REPLIES 9
ChrisHemedinger
Community Manager

Check your YEARCUTOFF setting -- it might be set to 1926. 
See: YEARCUTOFF option setting for SAS Viya 3.5 and older SAS 9.4 releases 

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
AMFR
Quartz | Level 8

Yes the YEARCUTOFF setting was 1926.

 

After changing it to 1940, EXCEL is giving me year as 2026.

 

Thank you very much

Quentin
Super User

Glad you got it working.

 

I suspect the problem was actually in your SAS dataset, not in the process of exporting the data to Excel.  Can you share how you exported the data to Excel?  

 

My understanding is the yearcutoff option only has an effect when SAS encounters a two-digit value and is asked to interpret it as a four-digit year.

 

Once you have a date variable (or date-time variable), the data is stored as a number (number of days or seconds since 01Jan1960).  So yearcutoff should not have any impact, as I understand it.

 

When I run below, the date-time is correctly exported to Excel, as I would expect:

options yearcutoff=1926 ;

data have ;
  mydate="01Jan2026:12:54"dt ;
  format mydate datetime. ;
run ;

proc export data=have outfile="Q:\junk\want.xlsx" dbms=xlsx replace;
run ;

My guess is if changing yearcutoff fixed the problem, that means somewhere in your code or data you have a two-digit year and you asked SAS to calculate a date-time from that value.

 

@ChrisHemedinger , is there really a case where the YEARCUTOFF value would effect the export process itself (assuming the exported data is a SAS date or date-time)?

ChrisHemedinger
Community Manager

I cannot say for sure, @Quentin . Since there are many ways to "export" to Excel (in UIs and code engines), it's possible that some methods would use the formatted value and if that featured a 2-digit year, then YEARCUTOFF could play a part. So...better to have a fully qualified format plus a reasonable setting for YEARCUTOFF!

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
Quentin
Super User

If you have a date-time variable in a SAS dataset, and you're exporting the data to Excel, I don't see how Excel could end up with a value that is 100 years off. 

 

But it's hard to guess at what might be going wrong without more info.  Can you show the code for how you export the data to Excel?

 

Can you post example data that replicates the problem?  For example, if you export the below dataset, do you see the problem?

 

data have ;
  mydate="01Jan2026:12:54"dt ;
  format mydate datetime19. ;
run ;

I think it's most likely that the date-time value in your SAS dataset is actually 1/1/1926 12:54, due to a problem earlier in your code.

 

ChrisHemedinger
Community Manager

In @Quentin's reply he includes a hint, which is that a fully qualified SAS format can make the difference. DATETIME is not the same as DATETIME19, and your data might be using the former -- which could leave it vulnerable to a YEARCUTOFF ambiguity when the formatted date value is exported.

ChrisHemedinger_0-1767638413082.png

 

 

 

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
Ksharp
Super User
As Quentin said, it is hard to give you some advice before you posted an example to replicate your issue.
Post your sample data and the code you are using.
AMFR
Quartz | Level 8

Thank you. Next time I will post the codes as well.

Kurt_Bremser
Super User
Please provide the complete log of the export step, and also tell us which format is assigned to the datetime variable. If it is a custom format, do also supply the PROC FORMAT code.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 410 views
  • 10 likes
  • 5 in conversation