Functions and CALL Routines |
Category: | Date and Time |
Syntax | |
Arguments | |
Details | |
Time Series Analysis: The Basics | |
Custom Intervals | |
Retail Calendar Intervals | |
Examples | |
See Also |
Syntax |
INTCK(interval<multiple><.shift-index>, start-from, increment, <'alignment'>) |
INTCK(custom-interval, start-from, increment, <'alignment'>) |
specifies a character constant, a variable, or an expression that contains an interval name. Interval can appear in uppercase or lowercase. The possible values of interval are listed in the Intervals Used with Date and Time Functions table in SAS Language Reference: Concepts.
Requirement: | The type of interval (date, datetime, or time) must match the type of value in from. |
Multipliers and shift indexes can be used with the basic interval names to construct more complex interval specifications. The general form of an interval name is as follows:
The three parts of the interval name are
specifies the name of the basic interval type. For example, YEAR specifies yearly intervals.
specifies an optional multiplier that sets the interval equal to a multiple of the period of the basic interval type. For example, the interval YEAR2 consists of two-year, or biennial, periods.
See: | Incrementing Dates and Times by Using Multipliers and by Shifting Intervalsfor more information. |
specifies a user-defined interval that is defined by a SAS data set. Each observation contains two variables, begin and end.
See: | Details for more information about custom intervals. |
Requirement: | You must use the INTERVALDS system option if you use the custom-interval variable. |
specifies an optional shift index that shifts the interval to start at a specified subperiod starting point. For 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.
Restriction: | 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. |
Restriction: | 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, MONTH type intervals shift by MONTH subperiods by default. Thus, 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. |
See: | Incrementing Dates and Times by Using Multipliers and by Shifting Intervalsfor more information. |
specifies a SAS expression that represents the starting SAS date, time, or datetime value.
specifies a SAS expression that represents the ending SAS date, time, or datetime value.
controls the position of SAS dates within the interval. You must enclose alignment in quotation marks. Alignment can be one of these values:
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.
Alias: | D or DISC |
Details |
Times series analysis uses time intervals to analyze events. All values within the interval are interpreted as being equivalent. This means that the dates of January 1, 2005 and January 15, 2005 are equivalent when you specify a monthly interval. Both of these dates represent the interval that begins on January 1, 2005 and ends on January 31, 2005. You can use the date for the beginning of the interval (January 1, 2005) or the date for the end of the interval (January 31, 2005) to identify the interval. These dates represent all of the dates within the monthly interval.
In the example intck('qtr','14JAN2005'd,'02SEP2005'd); , the start-from argument ('14JAN2005'd) is equivalent to the first quarter of 2005. The increment argument ('02SEP2005'd) is equivalent to the third quarter of 2005. The interval count, that is, the number of times the beginning of an interval is reached in moving from the start-from argument to the increment argument is 2.
WEEK intervals are determined by the number of Sundays that occur between the start-from argument and the increment argument, and not by how many seven-day periods fall between the start-from argument and the increment argument.
Both the multiple and the shift-index arguments are optional and default to 1. For example, YEAR, YEAR1, YEAR.1, and YEAR1.1 are all equivalent ways of specifying ordinary calendar years.
For more information about working with date and time intervals, see Date and Time Intervals.
A custom interval is defined by a SAS data set. The data set must contain two variables, begin and end. Each observation represents one interval with the begin variable containing the start of the interval, and the end variable containing the end of the interval. The intervals must be listed in ascending order. You cannot have gaps between intervals, and intervals cannot overlap.
The SAS system option INTERVALDS is used to define custom intervals and associate interval data sets with new interval names. The following example shows how to specify the INTERVALDS system option:
options intervalds=(interval=libref.dataset-name);
where
specifies the name of an interval. The value of interval is the data set that is named in libref.dataset-name.
specifies the libref and data set name of the file that contains user-supplied holidays.
The retail industry often accounts for its data by dividing the yearly calendar into four 13-week periods, based on one of the following formats: 4-4-5, 4-5-4, or 5-4-4. The first, second, and third numbers specify the number of weeks in the first, second, and third month of each period, respectively. For more information, see Retail Calendar Intervals: ISP 8601 Compliant in SAS Language Reference: Concepts.
Examples |
The following SAS statements produce these results:
In the second example, INTCK returns a value of 1 even though only one day has elapsed. This result is because the interval from December 31, 1994, to January 1, 1995, contains the starting point for the YEAR interval. However, in the third example, a value of 0 is returned even though 364 days have elapsed. This result is because the period between January 1, 1994, and December 31, 1994, does not contain the starting point for the interval.
In the fourth example, SAS returns a value of 6 because January 1, 1995, through January 1, 1998, 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 of January 1, 1997, through March 31, 1997. In the sixth example, SAS returns the value 26. That indicates that beginning with January 1, 1997, and counting only Saturdays as weekend days through February 1, 1997, the period contains 26 weekdays.
In the seventh example, the use of variables for the arguments is illustrated. The use of expressions for the arguments is illustrated in the last example.
See Also |
| |||
System Options: |
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.