BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
POOJA_J
Obsidian | Level 7
data demo;
input pid bdate: date9. svdate: date9.;
format bdate svdate date9.;

days=intck('day',bdate,svdate);
months=intck('month',bdate,svdate);
years=intck('year',bdate,svdate);
usingyrdiff= int(yrdif(bdate, svdate, 'actual'));  
cards;
101 19mar1978 14feb2005
102 20may1975 19mar2006
;
run;
proc print data=demo;
run;

Intck yr vs yrdiff.png

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

In its default setting, INTCK counts the number of interval boundaries between the values. Somebody born on December 31 will be one year old on January 1. To avoid this, you must use the "c" (continuous) modifier.

View solution in original post

3 REPLIES 3
Cynthia_sas
SAS Super FREQ

Hi:

  Take a look at this blog article. I think it explains your experience with INTCK https://blogs.sas.com/content/iml/2017/05/15/intck-intnx-intervals-sas.html . Basically, INTCK returns the number of "boundary dates" that have passed. So you need to control for that. There are also some good references at the end of the article.

Cynthia

PaigeMiller
Diamond | Level 26
data demo;
input pid bdate: date9. svdate: date9.;
format bdate svdate date9.;

days=intck('day',bdate,svdate,'c');
months=intck('month',bdate,svdate,'c');
years=intck('year',bdate,svdate,'c');
usingyrdiff= int(yrdif(bdate, svdate, 'actual'));  
cards;
101 19mar1978 14feb2005
102 20may1975 19mar2006
;
run;
--
Paige Miller
Kurt_Bremser
Super User

In its default setting, INTCK counts the number of interval boundaries between the values. Somebody born on December 31 will be one year old on January 1. To avoid this, you must use the "c" (continuous) modifier.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 456 views
  • 0 likes
  • 4 in conversation