INTCYCLE Function

Returns the date, time, or datetime interval at the next higher seasonal cycle when a date, time, or datetime interval is specified.

Category: Date and Time

Syntax

Required Arguments

interval

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.

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:

interval<multiple.shift-index>

The three parts of the interval name are listed below:

interval

specifies the name of the basic interval type. For example, YEAR specifies yearly intervals.

multiple

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 Intervals for more information.

shift-index

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 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.
See Incrementing Dates and Times by Using Multipliers and by Shifting Intervals for more information.

Optional Argument

seasonality

specifies a numeric value.

This argument enables you to have more flexibility in working with dates and time cycles. You can specify whether you want a 52-week or a 53-week seasonality in a year.
Example In the following example, the function
INTCYCLE('MONTH', 3);
has a seasonality argument and returns the value QTR. The function
INTCYCLE('MONTH');
does not have a seasonality argument and returns the value YEAR.

Details

The Basics

The INTCYCLE function returns the interval of the seasonal cycle, depending on a date, time, or datetime interval. For example, INTCYCLE('MONTH'); returns the value YEAR because the months from January through December constitute a yearly cycle. INTCYCLE('DAY'); returns the value WEEK because the days from Sunday through Saturday constitute a weekly cycle.
See Incrementing Dates and Times by Using Multipliers and by Shifting Intervals for information about multipliers and shift indexes. See Commonly Used Time Intervals for information about how intervals are calculated.
For more information about working with date and time intervals, see Date and Time Intervals .
The INTCYCLE function can also be used with calendar intervals from the retail industry. These intervals are ISO 8601 compliant. For more information, see Retail Calendar Intervals: ISO 8601 Compliant.

Seasonality

Seasonality is a time series concept that measures cyclical variations at different intervals during the year. In specifying seasonality, the time of year is the most common source of the variations. For example, sales of home heating oil are regularly greater in winter than during other times of the year. Often, certain days of the week cause regular fluctuations in daily time series, such as increased spending on leisure activities during weekends. The INTCYCLE function uses the concept of seasonality and returns the date, time, or datetime interval at the next higher seasonal cycle when a date, time, or datetime interval is specified. For more information about seasonality and using the forecasting methods in PROC FORCAST, see the SAS/ETS User's Guide.

Example

The following SAS statements produce these results.
SAS Statement
Result
cycle_year = intcycle('year');
put cycle_year;
YEAR
cycle_quarter = intcycle('qtr');
put cycle_quarter;
YEAR
cycle_3 = intcycle('month', 3);
put cycle_3;
QTR
cycle_month = intcycle('month');
put cycle_month;
YEAR
cycle_weekday = intcycle('weekday');
put cycle_weekday;
WEEK
cycle_weekday2 = intcycle('weekday', 5);
put cycle_weekday2;
WEEK
cycle_day = intcycle('day');
put cycle_day;
WEEK
cycle_day2 = intcycle('day', 10);
put cycle_day2;
TENDAY
var1 = 'second';
cycle_second = intcycle(var1);
put cycle_second;
DTMINUTE

See Also

Other References:
SAS/ETS User's Guide