Returns the number of interval boundaries of a given kind that lie between two SAS dates, times, or timestamp values encoded as DOUBLE.
Category: | Date and Time |
Returned data type: | DOUBLE |
specifies a basic or complex interval. Multipliers and shift indexes can be used with the basic interval names to construct more complex interval specifications. The three parts of the interval name are as follows:
specifies a character constant, a variable, or an expression that contains an interval name such as WEEK, MONTH, or QTR.
Data type | CHAR |
Note | The possible values of interval are listed in Intervals Used with Date and Time Functions in SAS Language Reference: Concepts. |
Tip | Interval can appear in uppercase or lowercase. |
Example | YEAR specifies year-based intervals. |
specifies an optional multiplier that sets the interval equal to a multiple of the period of the basic interval type.
Data type | INTEGER |
See | Incrementing Dates and Times By Using Multipliers and By Shifting Intervals in SAS Functions and CALL Routines: Reference for more information. |
Example | YEAR2 specifies a two-year, or biennial, interval type. |
specifies an optional shift index that shifts the interval to start at a specified subperiod starting point.
Restrictions | The shift index cannot be greater than the number of subperiods in the whole interval. For example, you could use YEAR2.24, but YEAR2.25 would be an error because there is no 25th month in a two-year interval. |
If the default shift period is the same as the interval type, then only multiperiod intervals can be shifted with the optional shift index. For example, because MONTH type intervals shift by MONTH subperiods by default, monthly intervals cannot be shifted with the shift index. However, bimonthly intervals can be shifted with the shift index, because there are two MONTH intervals in each MONTH2 interval. For example, the interval name MONTH2.2 specifies bimonthly periods starting on the first day of even-numbered months. | |
Data type | INTEGER |
See | Incrementing Dates and Times By Using Multipliers and By Shifting Intervals in SAS Functions and CALL Routines: Reference for more information. |
Example | YEAR.3 specifies yearly periods shifted to start on the first of March of each calendar year and to end in February of the following year. |
specifies an expression that represents the starting SAS date, time, or timestamp value.
Data type | DOUBLE |
specifies an expression that represents the ending SAS date, time, or timestamp value.
Data type | DOUBLE |
specifies that intervals are counted using either a discrete or a continuous method.
specifies that continuous time is measured. The interval is shifted based on the starting date.
Alias | C or CONT |
specifies that discrete time is measured. The discrete method counts interval boundaries (for example, end of month).
Alias | D or DISC |
Default | DISCRETE |
Data type | CHAR |
select intck('qtr', date'2013-01-14', date'2013-09-02)';The end-date (September 2, 2013) is equivalent to the third quarter of 2013. The interval count, that is, the number of times the beginning of an interval is reached in moving from the start-date to the end-date is 2.
select intck('month', date'2013-01-01', date'2013-01-31');
select intck('month', date'2013-01-31', date'2013-02-01');
select intck('month', date'2013-02-01', date'2013-01-31');
Category
|
Interval
|
Definition
|
Default Starting Point
|
Shift Period
|
Example
|
Description
|
---|---|---|---|---|---|---|
Date
|
DAY
|
Daily intervals
|
Each day
|
Days
|
DAY3
|
Three-day intervals
starting on Sunday
|
|
WEEK
|
Weekly intervals of
seven days
|
Each Sunday
|
Days (1=Sunday …
7=Saturday)
|
WEEK.7
|
Weekly with Saturday
as the first day of the week
|
|
WEEKDAY
<daysW>
|
Daily intervals with
Friday-Saturday-Sunday
|
Each day
|
Days
|
WEEKDAY1W
|
Six-day week with Sunday
as a weekend day
|
|
|
counted as the same
day (five-day work week with a Saturday-Sunday weekend). days identifies
the weekend days by number (1=Sunday ... 7=Saturday). By default, days=17.
|
|
|
WEEKDAY35W
|
Five-day week with Tuesday
and Thursday as weekend days (W indicates that day 3 and day 5 are
weekend days)
|
|
TENDAY
|
Ten-day intervals (a
U.S. automobile industry convention)
|
First, 11th, and 21st
of each month
|
Ten-day periods
|
TENDAY4.2
|
Four ten-day periods
starting at the second TENDAY period
|
|
SEMIMONTH
|
Half-month intervals
|
First and 16th of each
month
|
Semi-monthly periods
|
SEMIMONTH2.2
|
Intervals from the 16th
of one month through the 15th of the next month
|
|
MONTH
|
Monthly intervals
|
First of each month
|
Months
|
MONTH2.2
|
February-March, April-May,
June-July, August-September, October-November, and December-January
of the following year
|
QTR
|
Quarterly (three-month)
intervals
|
January 1
|
Months
|
QTR3.2
|
Three-month intervals
starting on April 1, July 1, October 1, and January 1
|
|
April 1
|
||||||
July 1
|
||||||
October 1
|
||||||
SEMIYEAR
|
Semiannual (six-month)
intervals
|
January 1
|
Months
|
SEMIYEAR.3
|
Six-month intervals,
March-August, and September-February
|
|
July 1
|
||||||
|
YEAR
|
Yearly intervals
|
January 1
|
Months
|
|
|
Datetime
|
Add DT to any of the
date intervals
|
Interval that corresponds
to the associated date interval
|
Midnight of January
1, 1960
|
DTMONTH
|
||
DTWEEKDAY
|
||||||
Time
|
SECOND
|
Second intervals
|
Start of the day (midnight)
|
Seconds
|
|
|
MINUTE
|
Minute intervals
|
Start of the day (midnight)
|
Minutes
|
|
||
HOUR
|
Hourly intervals
|
Start of the day (midnight)
|
Hours
|
|
Statements
|
Results
|
---|---|
select intck('qtr', date'2013-01-10', date'2013-07-01'); |
2 |
select intck('year', date'2012-12-31', date'2013-01-01'); |
1 |
select intck('year', date'2013-01-01', date'2013-12-31'); |
0 |
select intck('semiyear', date'2010-01-01', date'2013-01-01'); |
6 |
select intck('week2.2', date'2013-01-07', date'2013-04-01'); |
6 |
select intck('weekday7w', date'2013-01-01', date'2013-02-01'); |
27 |
select intck('year', date'2003-09-01', date'2013-09-01'); |
10 |