The INTGET function
returns a time interval based on three date or datetime values. The
function first determines all possible intervals between the first
two dates, and then determines all possible intervals between the
second and third dates. If the intervals are the same, INTGET returns
that interval. If the intervals for the first and second dates differ,
and the intervals for the second and third dates differ, INTGET compares
the intervals. If one interval is a multiple of the other, then INTGET
returns the smaller of the two intervals. Otherwise, INTGET returns
a missing value. INTGET works best with dates generated by the INTNX
function whose alignment value is BEGIN.
In the following example,
INTGET returns the interval DAY2:
interval=intget('01mar00'd, '03mar00'd, '09mar00'd);
The interval between the first and second dates is DAY2, because
the number of days between March 1, 2000, and March 3, 2000, is two.
The interval between the second and third dates is DAY6, because the
number of days between March 3, 2000, and March 9, 2000, is six. DAY6
is a multiple of DAY2. INTGET returns the smaller of the two intervals.
In the following example,
INTGET returns the interval MONTH4:
interval=intget('01jan00'd, '01may00'd, '01may01'd);
The interval between the first two dates is MONTH4, because the number
of months between January 1, 2000, and May 1, 2000, is four. The interval
between the second and third dates is YEAR. INTGET determines that
YEAR is a multiple of MONTH4 (there are three MONTH4 intervals in
YEAR), and returns the smaller of the two intervals.
In the following example,
INTGET returns a missing value:
interval=intget('01Jan2006'd, '01Apr2006'd, '01Dec2006'd);
The interval between the first two dates is MONTH3, and the interval
between the second and third dates is MONTH8. INTGET determines that
MONTH8 is not a multiple of MONTH3, and returns a missing value.
The intervals that are
returned are valid SAS intervals, including multiples of the intervals
and shift intervals. Valid SAS intervals are listed in
Intervals Used with Date and Time Functions in SAS Language Reference: Concepts.
Note: If INTGET cannot determine
a matching interval, then the function returns a missing value. No
message is written to the SAS log.