## Calculating SAS Date for INTCK

Solved
Frequent Contributor
Posts: 119

# Calculating SAS Date for INTCK

Hi,

Ok, I have been multiplying the dates from 1960 forward using 365.25*Years etc. But there has to be an easier way. The today() is useful, but what about for other dates? Also, even the today gives me the proper year, but the age is one year too high because it calculates the year as 1/1. So, someone born on March 1st 1990 would be calculated as being 28 on Jan 1 2018, even though they are still 27.

Below is code. I am very busy learning SAS and this is a minor annoyance that will help me speed things up. Thanks. Placing "Age" in the third field of Intck appears to be one option, but are there others?

Libname Review'/folders/myfolders/Review' ;
Libname Learn'/folders/myfolders/Learn' ;
Libname myformat'/folders/myfolders/sasuser.v94' ;
Options fmtsearch=(myformat) ;

Data review.Prob9_4 ;
Set Learn.Hosp ;
AgeJan1 =  Intck('Year',DOB, 01/01/2006) ;
AgeToday = Intck('Year',DOB, today()) ; /*Need to calculate SAS Date*/
format DOB Date9. AgeJan1 AgeToday 3. ;
run ;

Proc print data=review.Prob9_4 noobs ;
run ;

Accepted Solutions
Solution
‎04-19-2018 02:33 PM
Frequent Contributor
Posts: 119

## Re: Calculating SAS Date for INTCK

Ok, so INTCK really looks at the interval, regardless of date month, so Yrdif is probably better. Also, even then, using the int function before Yrdif is needed to get the correct age. The code below works best. Thanks.

Data review.Prob9_4 ;
Set Learn.Hosp ;
AgeJan1 =  int(YrDif(DOB, '01Jan2006'd, 'Actual')) ;
AgeToday = int(YrDif(DOB, '19Apr2018'd,'Actual')) ; /*Need ot calculate SAS Date*/
format DOB Date9. AgeJan1 AgeToday 3. ;
run ;

All Replies
Super User
Posts: 22,820

## Re: Calculating SAS Date for INTCK

INTNX? What are you trying to do, calculate age?
Super User
Posts: 22,820

## Re: Calculating SAS Date for INTCK

And lookup INTCK, the last parameter is not being used.
Solution
‎04-19-2018 02:33 PM
Frequent Contributor
Posts: 119

## Re: Calculating SAS Date for INTCK

Ok, so INTCK really looks at the interval, regardless of date month, so Yrdif is probably better. Also, even then, using the int function before Yrdif is needed to get the correct age. The code below works best. Thanks.

Data review.Prob9_4 ;
Set Learn.Hosp ;
AgeJan1 =  int(YrDif(DOB, '01Jan2006'd, 'Actual')) ;
AgeToday = int(YrDif(DOB, '19Apr2018'd,'Actual')) ; /*Need ot calculate SAS Date*/
format DOB Date9. AgeJan1 AgeToday 3. ;
run ;
☑ This topic is solved.