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-2024.png

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.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 4 replies
  • 5396 views
  • 1 like
  • 3 in conversation