Previous Page | Next Page

Functions and CALL Routines

INTGET Function



Returns a time interval based on three date or datetime values.
Category: Date and Time

Syntax
Arguments
Details
INTGET Function Intervals
Retail Calendar Intervals
Examples
See Also

Syntax

INTGET(date-1, date-2, date-3)


Arguments

date

specifies a SAS date or datetime value.


Details


INTGET Function Intervals

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 the Intervals Used with Date and Time Functions table 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.  [cautionend]


Retail Calendar Intervals

The INTGET function can also be used with calendar intervals from the retail industry. These intervals are ISO 8601 compliant. For more information, see Retail Calendar Intervals: ISO 8601 Compliant in SAS Language Reference: Concepts.


Examples

The following examples produce these results:

SAS Statements Results
interval=intget('01jan00'd,'01jan01'd,'01may01'd);
put interval;
MONTH4
interval=intget('29feb80'd,'28feb82'd,'29feb84'd);
put interval;
YEAR2.2
interval=intget('01feb80'd,'16feb80'd,'01mar80'd);
put interval;
SEMIMONTH
interval=intget('2jan09'd,'2feb10'd,'2mar11'd);
put interval;
MONTH13.4
interval=intget('10feb80'd,'19feb80'd,'28feb80'd);
put interval;
DAY9.2
interval=intget('01apr2006:00:01:02'dt,
'01apr2006:00:02:02'dt,
'01apr2006:00:03:02'dt);
put interval;

MINUTE


See Also

Functions:

INTFIT Function

INTNX Function

Previous Page | Next Page | Top of Page