Understanding SAS Time Intervals

The Time Data Preparation task analyzes the variable assigned to the time ID role to detect the time interval of the data. SAS assumes that all of the values in the time ID variable are either date or datetime values and distinguishes between the values by their magnitude. This assumption fails if you have dates extending beyond July 21, 2196, or datetimes before January 1, 1960.
For many businesses, their time series data is equally spaced, or any two consecutive indices have the same difference between the time intervals. The following table shows an equally spaced time series with a one-year interval.
Year
Number of Sales
2012
42,100
2013
45,000
2014
47,000
2015
50,000
If the time interval cannot be detected from the variable that you assign, then you need to specify the interval and season length. For example, the following table shows an unequally spaced time series.
Year
Number of Sales
2009
32,100
2010
45,000
2014
47,000
2015
50,000
Often the time interval cannot be detected with transactional data (timestamped data that is recorded at no particular frequency). If this is the case, the task accumulates the data into observations that correspond to the interval that you specify. For nontransactional data, you might need to specify the interval and season length if there are numerous gaps (missing values) in the data. In this case, the task supplies the missing values. A validation routine checks the values of the time ID to determine whether they are spaced according to the interval that you specified.
The interval determines the frequency of the output. You can modify the time interval. You can change the interval from a higher frequency to a lower frequency or from a lower frequency to a higher frequency. Time intervals are specified in SAS by using character strings. Each of these strings is formed according to a set of rules that enables you to create an almost infinite set of attributes. For each time interval, you can specify the type (such as monthly or weekly), a multiplier, and a shift (the offset for the interval). You can specify a greater time interval than that found in the input data. A smaller interval should not be used, because a small interval will generate a large number of observations.
Seasonal cycle length specifies the length of a season. This value is populated automatically if the task can determine the season length from the time ID variable. However, you can specify a season length other than the default if you want to model a cycle in the data. For example, your data might contain a 13-week cycle, so you need to specify a 13-week season length.
Here is the syntax for an interval:
name<multipler><.shift>
Here is an explanation of each of the user-supplied values:
name
is the name of the interval.
multipler
specifies the multiplier of the interval. This value can be any positive number. By default, the multiplier is 1. For example, YEAR2 indicates a two-year interval.
.shift
specifies the starting point for the interval. By default, this value is one. A value greater than 1 shifts the start to a later point within the interval. The unit for the shift depends on the interval. For example, YEAR.4 specifies a shift of four months, so the year is from April 1 through March 31 of the following year.
The examples in the following table show how the values that you specify for the interval, season length, multiplier, and shift work together.
Interval Name (in SAS code format)
Default
Shift Period
Example
YEARm.s
January 1
Months
YEAR2.7 specifies an interval of every two years. Because the value for the shift is 7, the first month in the year is July.
QTRm.s
January 1
April 1
July 1
October 1
Months
QTR3.2 - three-month intervals starting on April 1, July 1, October 1, and January 1.
MONTHm.s
First of each
month
Months
MONTH2.2 - February-March, April-May, June-July, August-September, October-November, and December-January of the following year.
WEEKm.s
Each Sunday
Days
(1=Sunday . . .
7=Saturday)
WEEK6.3 specifies six-week intervals starting on Tuesdays.
DAYm.s
Each day
Days
DAY3 - three-day intervals starting on Sunday.