Table of Contents
In data analysis, particularly when working with time-series or demographic data, accurately calculating the duration between two specified points in time is a fundamental requirement. The SAS System provides powerful tools for handling dates, and among the most critical is the INTCK function, which stands for “interval count.” This specialized function allows users to determine the number of time intervals—such as days, weeks, months, or years—that occur between a starting date and an ending date, accounting for complex calendar logic.
Unlike simple arithmetic subtraction of date variables, which only returns the raw number of days between two SAS date values (measured as the number of days since January 1, 1960), the INTCK function applies standard calendar rules. This capability is essential for generating meaningful metrics, such as calculating employee tenure, determining the age of a financial product, or performing precise cohort analysis.
Mastering the INTCK Function in SAS
The INTCK function is perhaps the most versatile tool available in SAS for time interval calculations. Its primary strength lies in its ability to handle different time granularities without requiring complex custom logic. Whether you need to count elapsed months, fiscal quarters, or simple days, INTCK manages the varying lengths of these time spans automatically.
The core concept behind INTCK is the counting of interval boundaries. When calculating the difference in months, for example, INTCK counts how many times a month boundary (the first day of a calendar month) is crossed between the start and end dates. This behavior is crucial to understand, as it differs significantly from calculating the exact number of days and dividing by the average length of the interval.
For advanced calculations, INTCK provides optional modifiers that allow users to specify how interval boundaries should be defined, such as starting weeks on a specific day (e.g., Monday instead of Sunday) or adhering to specific fiscal year definitions. These modifiers ensure that the calculated intervals align perfectly with specific business or analytical requirements, offering a high degree of precision and customization.
Understanding the Syntax and Arguments of INTCK
To effectively utilize this powerful function, it is necessary to grasp its precise syntax and the role of its four key arguments. The structure is straightforward, yet highly flexible, allowing for various calculation methodologies.
The fundamental syntax for the INTCK function is:
INTCK(interval, start date, end date, method)
The arguments are defined as follows:
- interval: This mandatory argument specifies the unit of time you wish to count (e.g.,
'DAY','WEEK','MONTH','YEAR','QTR'). The chosen interval dictates how SAS interprets the elapsed time between the two dates. - start date: The date value marking the beginning of the period under review. This must be a valid SAS date value.
- end date: The date value marking the conclusion of the period under review.
- method: This optional argument controls how intervals are counted. It determines whether the function should count complete intervals only (‘C’) or partial intervals (‘D’ or default).
The method argument is particularly important, as the default behavior (‘D’ for Discrete) counts every interval boundary crossed, leading to results that might seem inflated if the user expects a count of only full, elapsed periods. Using the ‘C’ method, which stands for Continuous or Complete, restricts the count only to those intervals that have fully completed between the start and end dates.
Practical Example: Setting Up the Date Dataset
To illustrate the application of the INTCK function, we will first establish a sample dataset containing several pairs of start and end dates. This initial step ensures that the dates are correctly recognized by SAS using the appropriate date format.
In SAS, date values are numeric, and the `FORMAT` statement is necessary to display these numbers as human-readable dates (e.g., 01JAN2022). The following code block creates our source data, ensuring the dates are interpreted and stored correctly.
/*create dataset*/
data original_data;
format start_date end_date date9.;
input start_date :date9. end_date :date9.;
datalines;
01JAN2022 09JAN2022
01FEB2022 22FEB2022
14MAR2022 04APR2022
01MAY2022 14AUG2022
;
run;
/*view dataset*/
proc print data=original_data;The resulting table, displayed below, confirms that the dataset has been correctly loaded with four observations, each containing a start and an end date.

With the source data prepared, we can proceed to apply the INTCK function to calculate the time difference across various intervals—specifically, days, weeks, and months—using the default method, which counts partial intervals.
Calculating Differences Using Default INTCK (Partial Intervals)
The default behavior of INTCK, corresponding to the ‘D’ method (Discrete), counts every instance where an interval boundary is crossed, even if the resulting interval is incomplete. For instance, if calculating the difference in weeks, the function counts the number of Sunday boundaries (by default) that occur between the two dates. This method is often preferred when analyzing the span of time covered, including incomplete segments.
We apply the function three times within a single DATA step, creating three new date variables: days_diff, weeks_diff, and months_diff. Note that in this code block, we omit the fourth argument, allowing INTCK to use the default ‘D’ (discrete) method.
/*create new dataset*/
data new_data;
set original_data;
days_diff = intck('day', start_date, end_date);
weeks_diff = intck('weeks', start_date, end_date);
months_diff = intck('months', start_date, end_date);
run;
/*view new dataset*/
proc print data=new_data;Reviewing the output below, we observe how the default method calculates the differences. Consider the first observation (Jan 1, 2022, to Jan 9, 2022). The difference in days is 8 (the actual number of days between the two dates). However, the difference in weeks is 2. This occurs because the period crosses two week boundaries (Sunday boundaries), even though the total elapsed time is only 8 days, which is less than two full weeks. This boundary-counting characteristic is the defining feature of the default method.

Similarly, for the third observation (March 14, 2022, to April 4, 2022), the calculated months difference is 1. This is because the calculation crosses the boundary from March into April, counting one month interval, even though the total time elapsed is less than a full calendar month.
Calculating Differences Using the ‘C’ Method (Complete Intervals)
When analytical questions require counting only those time periods that have fully elapsed—such as calculating a person’s age or the number of full quarters a financial instrument has existed—the ‘C’ method (Continuous or Complete) must be explicitly used within the INTCK function. This approach provides a conservative count, ensuring that only complete units of time are included in the final result.
To invoke this alternative counting method, we simply supply 'C' as the fourth argument in the function call. This subtle change drastically alters the interpretation of the results, providing a measure of fully completed periods rather than boundary crossings.
/*create new dataset*/
data new_data;
set original_data;
days_diff = intck('day', start_date, end_date, 'c');
weeks_diff = intck('weeks', start_date, end_date, 'c');
months_diff = intck('months', start_date, end_date, 'c');
run;
/*view new dataset*/
proc print data=new_data;When viewing the output generated by the ‘C’ method, the differences become clear. Focusing again on the first observation (Jan 1st to Jan 9th), the difference in weeks is now calculated as 1, down from 2 in the previous table. This is because only one full 7-day week can be contained within the 8-day span. Similarly, the difference in months for the third observation (March 14th to April 4th) is now 0, as a full calendar month did not elapse between the two dates.

Understanding the distinction between the default (‘D’) boundary-crossing method and the ‘C’ complete interval method is crucial for accurate time-based calculations in SAS. Choosing the appropriate method depends entirely on whether the analysis requires counting partial spans or only fully completed time units.
Deep Dive into INTCK Intervals and Date Handling
The power of the INTCK function is significantly enhanced by the vast array of intervals it supports. Beyond the basic DAY, WEEK, and MONTH, SAS offers specialized intervals tailored for fiscal, academic, and business calendar needs. For instance, intervals like QTR (quarter), YEAR, and SEMIYEAR are frequently used in financial reporting.
Furthermore, SAS allows for shifted intervals. For example, the WEEKV interval enables the user to specify a week starting day other than the default Sunday (e.g., WEEKV.2 defines the week as starting on Monday). This flexibility is necessary for aligning data processing with regional or organizational calendar standards, such as those where the work week begins mid-week.
It is also important to differentiate INTCK from its sibling function, INTNX (Interval Next). While INTCK counts the number of intervals *between* two dates, INTNX calculates a future or past date based on a starting date and a specified number of intervals. For example, INTNX can determine the date three months from today, whereas INTCK tells you how many months have passed since a historical date. Mastery of both functions is key to comprehensive SAS date manipulation.
Summary and Further Resources
The INTCK function is an indispensable tool for analysts and programmers working with temporal data in SAS. By providing a calendar-aware method for counting intervals, it moves far beyond the limitations of simple date subtraction. The choice between the default boundary-crossing method and the ‘C’ complete interval method depends entirely on the specific analytical question being addressed, but both methods are essential components of robust data processing.
We demonstrated how to set up date data, apply the INTCK function to calculate differences in days, weeks, and months, and critically, how the inclusion of the 'C' modifier alters the output to count only fully elapsed periods.
Additional Resources
The following tutorials explain how to perform other common tasks in SAS:
Cite this article
Mohammed looti (2025). Learning to Calculate Date Differences Using the INTCK Function in SAS. PSYCHOLOGICAL STATISTICS. Retrieved from https://statistics.arabpsychology.com/calculate-difference-between-two-dates-in-sas/
Mohammed looti. "Learning to Calculate Date Differences Using the INTCK Function in SAS." PSYCHOLOGICAL STATISTICS, 31 Oct. 2025, https://statistics.arabpsychology.com/calculate-difference-between-two-dates-in-sas/.
Mohammed looti. "Learning to Calculate Date Differences Using the INTCK Function in SAS." PSYCHOLOGICAL STATISTICS, 2025. https://statistics.arabpsychology.com/calculate-difference-between-two-dates-in-sas/.
Mohammed looti (2025) 'Learning to Calculate Date Differences Using the INTCK Function in SAS', PSYCHOLOGICAL STATISTICS. Available at: https://statistics.arabpsychology.com/calculate-difference-between-two-dates-in-sas/.
[1] Mohammed looti, "Learning to Calculate Date Differences Using the INTCK Function in SAS," PSYCHOLOGICAL STATISTICS, vol. X, no. Y, ص Z-Z, October, 2025.
Mohammed looti. Learning to Calculate Date Differences Using the INTCK Function in SAS. PSYCHOLOGICAL STATISTICS. 2025;vol(issue):pages.