Working with Time Series Data |
Interval Functions INTNX and INTCK
The SAS interval functions INTNX and INTCK perform calculations
with date, datetime values, and time intervals.
They can be used for calendar calculations with
SAS date values, to count time intervals between dates,
and to increment dates or datetime values by intervals.
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 containing
a given date or datetime value.
The form of the INTNX function is
INTNX( interval, from, n <, alignment > )
where:
- interval
- is a character constant or variable
containing an interval name.
- from
- is a SAS date value (for date intervals)
or datetime value (for datetime intervals).
- n
- is the number of intervals to increment from the
interval containing the from value.
- alignment
- controls the alignment of SAS dates, within the
interval, used to identify output observations.
Can take the values BEGINNING|B, MIDDLE|M, or END|E.
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 containing the value of DATE.
The INTCK function counts the number of interval boundaries
between two dates or between two datetime values.
The form of the INTCK function is
INTCK( interval, from, to )
where:
- interval
- is a character constant or variable containing an interval name
- from
- is the starting date (for date intervals)
or datetime value (for datetime intervals)
- to
- is the ending date (for date intervals)
or datetime value (for datetime intervals).
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.
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.