BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
anming
Pyrite | Level 9
data scoredata1;
set scoredata0;
year_diff1 = YRDIF(start_date,today(),'30/360');
year_diff2 = YRDIF(start_date,'14sep2015'd,'ACT/ACT');
year_diff3 = YRDIF(start_date,today(),'ACT/360');
year_diff4 = YRDIF(start_date,'14sep2015'd,'ACT/365');

day_diff1 = datDIF(start_date,today(),'30/360');
day_diff2 = datDIF(start_date,'14sep2015'd,'ACT/ACT');

run;

 when I run the codes above, I got different values due to different bases. How can I sue these values? or what are the significance of these differences? 

 

Besides, why should we put 'd' after the date in date9 format?

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

The documentation explains the differences

https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=lefunctionsref&docsetTarg...

 

why should we put 'd' after the date in date9 format?

 

Formats are irrelevant, SAS does all calculations based upon the internal representation of the dates, which is the integer number of days since 01JAN1960. So whether the date is formatted or not, that's how it is represented. So when you use '14sep2015'd, the d at the end tells SAS to convert the date to the integer number of days since 01JAN1960, and now the math proceeds properly. If you leave of the d at the end, then SAS is trying to work with a character string '14sep2015' which is not a date and can't be evaluated in date arithmetic.

--
Paige Miller

View solution in original post

1 REPLY 1
PaigeMiller
Diamond | Level 26

The documentation explains the differences

https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=lefunctionsref&docsetTarg...

 

why should we put 'd' after the date in date9 format?

 

Formats are irrelevant, SAS does all calculations based upon the internal representation of the dates, which is the integer number of days since 01JAN1960. So whether the date is formatted or not, that's how it is represented. So when you use '14sep2015'd, the d at the end tells SAS to convert the date to the integer number of days since 01JAN1960, and now the math proceeds properly. If you leave of the d at the end, then SAS is trying to work with a character string '14sep2015' which is not a date and can't be evaluated in date arithmetic.

--
Paige Miller

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 lock in 2025 pricing—just $495!

Register now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 1139 views
  • 0 likes
  • 2 in conversation