Returns the cycle index when a date, time, or datetime interval and value are specified.
Category: Date and Time


Required Arguments

specifies a character constant, a variable, or an expression that contains an interval name such as WEEK, MONTH, or QTR. Interval can appear in uppercase or lowercase. The possible values of interval are listed in Intervals Used with Date and Time Functions in SAS Language Reference: Concepts.
If interval is a character constant, then enclose the value in quotation marks.
Valid values for interval depend on whether date-time-value is a date, time, or datetime value.
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 as follows:
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.
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.
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, then only multiperiod intervals can be shifted with the optional shift index. For example, because MONTH intervals shift by MONTH periods 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.

specifies a date, time, or datetime value that represents a time period of a specified interval.


The INTCINDEX function returns the index of the seasonal cycle when you specify an interval and a SAS date, time, or datetime value. For example, if the interval is MONTH, each observation in the data corresponds to a particular month. Monthly data is considered to be periodic for a one-year period. A year contains 12 months, so the number of intervals (months) in a seasonal cycle (year) is 12. WEEK is the seasonal cycle for an interval that is equal to DAY. Therefore, intcindex('day','01SEP78'd); returns a value of 35 because September 1, 1978, is the sixth day of the 35th week of the year. For more information about working with date and time intervals, see Date and Time Intervals.
The INTCINDEX function can also be used with calendar intervals from the retail industry. These intervals are ISO 8601 compliant. For a list of these intervals, see “Retail Calendar Intervals: ISO 8601 Compliant” in SAS Language Reference: Concepts.


The INTCINDEX function returns the cycle index, whereas the INTINDEX function returns the seasonal index.
In the example cycle_index = intcindex('day','04APR2005'd);, the INTCINDEX function returns the week of the year. In the example index = intindex('day','04APR2005'd);, the INTINDEX function returns the day of the week.
In the example cycle_index = intcindex('minute','01Sep78:00:00:00'dt);, the INTCINDEX function returns the hour of the day. In the example index = intindex('minute','01Sep78:00:00:00'dt);, the INTINDEX function returns the minute of the hour.
In the example intseas(intcycle('interval'));, the INTSEAS function returns the maximum number that could be returned by intcindex('interval',date);.


The following SAS statements produce these results.
SAS Statement
cycle_index1 = intcindex('day', '01SEP05'd);
put cycle_index1;
cycle_index2 = intcindex('dtqtr', '23MAY2005:05:03:01'dt);
put cycle_index2;
cycle_index3 = intcindex('tenday', '13DEC2005' d);
put cycle_index3;
cycle_index4 = intcindex('minute', '23:13:02't);
put cycle_index4;
var1 = 'semimonth';
cycle_index5 = intcindex(var1, '05MAY2005:10:54:03'dt);
put cycle_index5;