Chapter Contents |
Previous |
Next |
INTCK |
Category: | Date and Time |
Syntax | |
Arguments | |
Details | |
Examples | |
See Also |
Syntax |
INTCK('interval',from,to) |
Date Intervals | Datetime Intervals | Time Intervals |
---|---|---|
DAY | DTDAY | HOUR |
WEEKDAY | DTWEEKDAY | MINUTE |
WEEK | DTWEEK | SECOND |
TENDAY | DTTENDAY | |
SEMIMONTH | DTSEMIMONTH | |
MONTH | DTMONTH | |
QTR | DTQTR | |
SEMIYEAR | DTSEMIYEAR | |
YEAR | DTYEAR |
Requirement: | The type of interval (date, datetime, or time) must match the type of value in from. |
Details |
The INTCK function counts intervals by using a fixed starting point for the interval as opposed to counting in multiples of the interval unit. Partial intervals are not counted. For example, WEEK intervals are determined by the number of Sundays that begin between the from and the to, not by how many seven-day periods fall in between the from and the to.
Examples |
SAS Statements | Results |
---|---|
qtr=intck('qtr','10jan95'd,'01jul95'd); put qtr; |
2 |
year=intck('year','31dec94'd, '01jan95'd); put year; |
1 |
year=intck('year','01jan94'd, '31dec94'd); put year; |
0 |
semi=intck('semiyear','01jan95'd, '01jan98'd); put semi; |
6 |
weekvar=intck('week2.2','01jan97'd, '31mar97'd); put weekvar; |
6 |
wdvar=intck('weekday7w','01jan97'd, '01feb97'd); put wdvar; |
26 |
In the second example, INTCK returns a value of 1 even though only one day has elapsed. This is because the interval from December 31, 1994 to January , 1995 contains the starting point for the YEAR interval. In the third example, however, a value of 0 is returned even though 364 days have elapsed. This is because the period between the two dates does not contain the starting point for the interval.
In the fourth example, SAS returns a value of 6 because the time period contains six semiyearly intervals. (Note that if the ending date were December 31, 1997, SAS would count five intervals.) In the fifth example, SAS returns a value of 6 because there are six two-week intervals beginning on a first Monday during the period. In the sixth example, SAS returns the value 26. That indicates that beginning with January 1, 1997, and counting only Saturdays as weekend days, the period contains 26 weekdays.
See Also |
Function:
|
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.