The SAS interval functions INTNX and INTCK perform calculations with date values, datetime values, and time intervals. They can be used for calendar calculations with SAS date values to increment date values or datetime values by intervals and to count time intervals between dates.
The INTNX function increments dates by intervals. INTNX computes the date or datetime of the start of the interval a specified number of intervals from the interval that contains a given date or datetime value.
The form of the INTNX function is
INTNX ( interval, from, n < , alignment > );
The arguments to the INTNX function are as follows:
The number of intervals to increment, n, can be positive, negative, or zero.
For example, the statement NEXTMON=INTNX(’MONTH’,DATE,1) assigns to the variable NEXTMON the date of the first day of the month following the month that contains the value of DATE. Thus INTNX(’MONTH’,’21OCT2007’D,1) returns the date 1 November 2007.
The INTCK function counts the number of interval boundaries between two date values or between two datetime values.
The form of the INTCK function is
INTCK ( interval, from, to );
The arguments of the INTCK function are as follows:
For example, the statement NEWYEARS=INTCK(’YEAR’,DATE1,DATE2) assigns to the variable NEWYEARS the number of New Year’s Days between the two dates.