Returns the shift interval that corresponds to the base interval.
Category: Date and Time


INTSHIFT(interval <<multiple.<shift-index> > > )

Required Arguments

specifies a character constant, a variable, or an expression that contains a time interval such as WEEK, SEMIYEAR, QTR, or HOUR. 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:
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 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.


The INTSHIFT function returns the shift interval that corresponds to the base interval. For custom intervals, the value that is returned is the base custom interval name. INTSHIFT ignores multiples of the interval and interval shifts.
The INTSHIFT 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 in SAS Language Reference: Concepts.


The following SAS statements produce these results.
SAS Statement
shift1 = intshift('year');
put shift1;
shift2 = intshift('dtyear');
put shift2;
shift3 = intshift('minute');
put shift3;
interval = 'weekdays';
shift4 = intshift(interval);
put shift4;
shift5 = intshift('weekday5.4');
put shift5;
shift6 = intshift('qtr');
put shift6;
shift7 = intshift('dttenday');
put shift7;