Working with Time Series Data


Specifying Time Intervals

Intervals are specified in SAS by using interval names such as YEAR, QTR, MONTH, DAY, and so forth. Table 4.3 summarizes the basic types of intervals.

Table 4.3: Basic Interval Types

Name

Periodicity

YEAR

yearly

SEMIYEAR

semiannual

QTR

quarterly

MONTH

monthly

SEMIMONTH

1st and 16th of each month

TENDAY

1st, 11th, and 21st of each month

WEEK

weekly

WEEKDAY

daily ignoring weekend days

DAY

daily

HOUR

hourly

MINUTE

every minute

SECOND

every second


Interval names can be abbreviated in various ways. For example, you could specify monthly intervals as MONTH, MONTHS, MONTHLY, or just MON. SAS accepts all these forms as equivalent.

Interval names can also be qualified with a multiplier to indicate multi-period intervals. For example, biennial intervals are specified as YEAR2.

Interval names can also be qualified with a shift index to indicate intervals with different starting points. For example, fiscal years starting in July are specified as YEAR.7.

Intervals are classified as either date or datetime intervals. Date intervals are used with SAS date values, while datetime intervals are used with SAS datetime values. The interval types YEAR, SEMIYEAR, QTR, MONTH, SEMIMONTH, TENDAY, WEEK, WEEKDAY, and DAY are date intervals. HOUR, MINUTE, and SECOND are datetime intervals. Date intervals can be turned into datetime intervals for use with datetime values by prefixing the interval name with 'DT'. Thus DTMONTH intervals are like MONTH intervals but are used with datetime ID values instead of date ID values.

See ChapterĀ 5: Date Intervals, Formats, and Functions, for more information about specifying time intervals and for a detailed reference to the different kinds of intervals available.