Multi-unit intervals,
such as MONTH2 or DAY50, also depend on calendar measures, but they
introduce a new problem: SAS can find the beginning of a unit (for
example, the first of a month), but where does that unit fall in the
interval? For example, does the first of October mark the first or
the second month in a two-month interval?
For all multi-unit intervals
except multi-week intervals, SAS creates an interval beginning on
January 1, 1960, and counts forward from that date to determine where
individual intervals begin on the calendar. As a practical matter,
when a year can be divided evenly by an interval, think of the intervals
as beginning with the current year. Thus, MONTH2 intervals begin with
January, March, May, July, September, and November. Consider this
example:
Month2 Intervals
|
|
howmany1=intck('month2','15feb2000'd,
'15mar2000'd);
|
|
count=intck('day50','01oct1998'd,
'01jan1999'd);
|
|
In the above example,
SAS counts 50 days beginning with January 1, 1960; then another 50
days; and so on. As part of this count, SAS counts one DAY50 interval
between October 1, 1998, and January 1, 1999. For example, to determine
the date on which the next DAY50 interval begins, use the INTNX function,
as follows:
Using the INTNX Function
|
|
start=intnx('day50','01oct98'd,1);
|
SAS date value 14200,
or Nov 17, 1998
|
The next interval begins
on November 17, 1998.
Time intervals (those
that represent divisions of a day) are aligned with the start of the
day, that is, midnight. For example, HOUR8 intervals divide the day
into the periods 00:00 to 08:00, 8:00 to 16:00, and 16:00 to 24:00
(the next midnight).