INTCK Function: DISCRETE and CONTINUOUS Methods in SAS

The INTCK function in SAS returns the number of interval boundaries that lie between two SAS dates, times, or timestamp values.

It’s a super powerful function in SAS which is being used widely when calculating date intervals between two dates.

Syntax of INTCK function:

				INTCK(interval , start-date-time, end-date-time, <'method'>)
			

method: – It’s an optional parameter. You can define a method to calculate differences. The default is “DISCRETE” but you can specify if you want to use the “CONTINUOUS” method. 

When you use the INTCK function by default it is considered as a DISCRETE method unless and until you specify it as a CONTINUOUS method.

What is Discrete method?

A set of data is said to be discrete if the values belonging to the set are distinct and separate (unconnected values).

What is Continuous method?

A set of data is said to be continuous if the values belonging to the set can take on ANY value within a finite or infinite interval.

INTCK DISCRETE Function in SAS
INTCK Continuous Function in SAS

Here is an example of the INTCK function with DISCRETE method:

				data descrete_intck;
	month1=intck('month', '01MAR2030'd, '31MAR2030'd);
	month2=intck('month', '25MAR2030'd, '05APR2030'd);
	month3=intck('month', '25MAR2030'd, '25APR2030'd);

proc print data=descrete_intck;
run;
			
INTCK Function with DESCRETE method in SAS

Is there anything wrong with the above result? 

Look at the month2 variable. It says, one month is the difference between 25MAR2023 and 05APR2030. Technically it has changed the month but when you calculate days, it is just 10 days difference between 25th March and 5th April. 

This is the problem with default DISCRETE method used in INTCK function. You can easily solve this problem by using CONTINUOUS method in INTCK function. Here is an example:

				data continuous_intck;
	month1=intck('month', '01MAR2030'd, '31MAR2030'd, 'C');
	month2=intck('month', '25MAR2030'd, '05APR2030'd, 'C');
	month3=intck('month', '25MAR2030'd, '25APR2030'd, 'C');

proc print data=continuous_intck;
run;
			
INTCK Function with CONTINUOUS method in SAS

Now look at the month2 variable now. There is a change in month but actual difference between the 25th Mar and 05 April is just 10 days, hence it is not counted month difference as one. 

Calculate Year Difference Between Two Dates

This example demonstrate clear difference between discrete and continuous method using in INTCK function.

  • With the discrete method only year change is enough to calculate the interval for INTCK function.
  • With the continuous method only year change is not considered as enough parameter to calculate the interval between two dates.

Let’s calculate year difference between two dates:

				data intck_demo;
	month_descrete=intck('year', '01MAR2030'd, '01JAN2031'd);
	month_continuous=intck('year', '01MAR2030'd, '01JAN2031'd, 'C');
	
proc print data=intck_demo;
run;
			
INTCK discrete and continuous function in SAS

FAQ

What is Discrete function?

A set of data is said to be discrete if the values belonging to the set are distinct and separate (unconnected values).

What is Continuous function?

A set of data is said to be continuous if the values belonging to the set can take on ANY value within a finite or infinite interval.