BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Cruise
Ammonite | Level 13

I'd like to do a quick check If I'm missing something obvious here? Output from below is a future date 09/02/2076. Any idea why?

 

data p.a;

a=42614;

format a mmddyy10.;

run;

 

Thanks a lot.

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Oh. This looks like data imported from MS Excel. If somehow the fact that a date is concerned gets missed during the import from Excel to SAS, raw Excel dates will look like this, as Excel counts days from 1899-12-31. See this for reference:

data _null_;
x1 = 44227;
diff = '01jan1960'd - '30dec1899'd;
x1 = x1 - diff;
format x1 yymmddd10.;
put x1=;
run;

 

Edit: corrected Excel basedate to 1899-12-30 (1960-01-01 in SAS is 0, 1900-01-01 in Excel is 1, but because of the "leapyear 1900" bug in Excel it actually has to be 2)

View solution in original post

4 REPLIES 4
andreas_lds
Jade | Level 19

From the documentation:

"A SAS date value is a value that represents the number of days between January 1, 1960, and a specified date. SAS can perform calculations on dates ranging from A.D. 1582 to A.D. 19,900. Dates before January 1, 1960, are negative numbers; dates after are positive numbers."

Kurt_Bremser
Super User

A date value in SAS is the count of days starting at 1960-01-01 (days before that have a negative value). If you count 42614 days from that, you arrive at that date in 2076. Today's date is 21360 as a raw numerical value:

data _null_;
x1 = today();
put x1=;
run;
Cruise
Ammonite | Level 13

Yes, sorry for making my question unclear. I'm surprised because these are supposed to be dates for the start date of clinical trials in the past. I'm not supposed to have future dates. And I wonder how come?

date.png

Kurt_Bremser
Super User

Oh. This looks like data imported from MS Excel. If somehow the fact that a date is concerned gets missed during the import from Excel to SAS, raw Excel dates will look like this, as Excel counts days from 1899-12-31. See this for reference:

data _null_;
x1 = 44227;
diff = '01jan1960'd - '30dec1899'd;
x1 = x1 - diff;
format x1 yymmddd10.;
put x1=;
run;

 

Edit: corrected Excel basedate to 1899-12-30 (1960-01-01 in SAS is 0, 1900-01-01 in Excel is 1, but because of the "leapyear 1900" bug in Excel it actually has to be 2)

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 6014 views
  • 1 like
  • 3 in conversation