INTFMT Function

Returns a recommended SAS format when a date, time, or datetime interval is specified.

Category: Date and Time

Syntax

INTFMT(interval<<multiple.<.shift-index> > > , 'size')

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 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 as follows:

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.

'size'

specifies either LONG or SHORT. When a format includes a year value, LONG or L specifies a format that uses a four-digit year. SHORT or S specifies a format that uses a two-digit year.

Details

The INTFMT function returns a recommended format depending on a date, time, or datetime interval for displaying the time ID values that are associated with a time series of a given interval. The valid values of SIZE (LONG, L, SHORT, or S) specify whether to use a two-digit or a four-digit year when the format refers to a SAS date value. For more information about working with date and time intervals, see Date and Time Intervals .
The INTFMT 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.

Example

The following SAS statements produce these results.
SAS Statement
Result
fmt1 = intfmt('qtr', 's');
put fmt1;
YYQC4.
fmt2 = intfmt('qtr', 'l');
put fmt2;
YYQC6.
fmt3 = intfmt('month', 'l');
put fmt3;
MONYY7.
fmt4 = intfmt('week', 'short');
put fmt4;
WEEKDATX15.
fmt5 = intfmt('week3.2', 'l');
put fmt5;
WEEKDATX17.
fmt6 = intfmt('day', 'long');
put fmt6;
DATE9.
var1 = 'month2';
fmt7 = intfmt(var1, 'long');
put fmt7;
MONYY7.