The TIMEID Procedure

Example 37.1 Examining a Weekly Time ID Variable

(View the complete code for this example.)

This example illustrates how problems in a weekly time series can be visualized and quantified using the TIMEID procedure’s diagnostic capabilities.

The following DATA step creates a data set that contains time values spaced in three-week intervals where some weeks have been skipped or duplicated and some have been recorded on different weekdays:

data triweek;
   format date date.;
   input date : date. @@;
datalines;
28DEC48 18JAN49 08FEB49 01MAR49 22MAR49 12APR49 03MAY49 24MAY49
17JUN49 05JUL49 26JUL49 16AUG49 06SEP49 27SEP49 18OCT49 08NOV49
29NOV49 20DEC49 10JAN50 04FEB50 21FEB50 14MAR50 04APR50 25APR50

   ... more lines ...   

The following TIMEID procedure statements generate an ODS display of the time series that characterizes interval counts, offsets, and spans in the time ID variable:

proc timeid data=triweek print=all plot=all;
  id date interval=week3;
run;


The Time ID decomposition listing and plot shown in Output 37.1.1 and Output 37.1.2 summarize how well the WEEK3 interval fits the time ID values by showing the number of counts, offsets, and spans for each time interval that is represented by the DATE variable. The listing in Output 37.1.1 has been truncated to include only the first 10 observations. The Time ID plots in Output 37.1.2 indicate that there are duplicated time ID values for a three-week time interval in the Counts plot. The duplicated time intervals have a Count value of 2. The Offsets plot shows which days in the 21 day cycle have been used to record each time interval in the series. The Spans plot records values of 2 for six time intervals where no observations were recorded in the previous interval. The three component plots are histogram summaries of the diagnostic quantities plotted against individual intervals in the decomposition plots. The component plots can be useful in diagnosing time series that contain many time intervals.

Output 37.1.1: Time ID Decomposition Listing

Time Component
Value
Index
dateOffsetSpanInterval
Count
1Sun, 12 Dec 194816.1
2Sun, 2 Jan 19491611
3Sun, 23 Jan 19491611
4Sun, 13 Feb 19491611
5Sun, 6 Mar 19491611
6Sun, 27 Mar 19491611
7Sun, 17 Apr 19491611
8Sun, 8 May 19491611
9Sun, 29 May 19491911
10Sun, 19 Jun 19491611


Output 37.1.2: Time ID Decomposition Plot

Time ID Decomposition Plot


Output 37.1.3 and Output 37.1.4 describe the distribution of counts of duplicated WEEK3 intervals in the TriWeek data set. For this data set there are 134 intervals that contain one DATE value, and 10 intervals that contain two DATE values.

Output 37.1.3: Time ID Interval Counts Listings

The TIMEID Procedure

Component
Value
Index
Interval
Count
FrequencyPercentage
1113291.666667
22128.333333

Statistics Summary
MinimumMaximumMeanStandard
Deviation
121.08333331.3008873


Output 37.1.4: Time ID Interval Counts Histogram

Time ID Interval Counts Histogram


The offsets diagnostics Output 37.1.5 and Output 37.1.6 show the distribution of days in the 21-day WEEK3 interval used to record the time intervals in the series. The observations in the TriWeek data set represent intervals with five different offsets from the beginning of the WEEK3 interval: 0, 16, 18, 19, and 20. The high prevalence of intervals with offset 16 indicates that the TriWeek data set would be represented better using the WEEK3.17 interval.

Output 37.1.5: Time ID Offsets Listings

The TIMEID Procedure

Component
Value
Index
OffsetFrequencyPercentage
1010.694444
21613895.833333
31810.694444
41910.694444
52032.083333

Statistics Summary
MinimumMaximumMeanStandard
Deviation
02016.0069441.7006205


Output 37.1.6: Time ID Offsets Histogram

Time ID Offsets Histogram


The span diagnostics Output 37.1.7 and Output 37.1.8 show the distribution of the span sizes between successive DATE values. The TriWeek data set has three different span sizes of widths 0, 1, and 2. Here one span corresponds to the width of a WEEK3 interval.

Output 37.1.7: Time ID Span Listings

The TIMEID Procedure

Component
Value
Index
SpanFrequencyPercentage
1010.704225
2113595.070423
3264.225352

Statistics Summary
MinimumMaximumMeanStandard
Deviation
021.03521130.6367974


Output 37.1.8: Time ID Span Histogram

Time ID Span Histogram


Output 37.1.9 and Output 37.1.10 show the distribution of time ID values before alignment to the WEEK3 interval. The listing in Output 37.1.9 has been truncated to include only the first 10 observations.

Output 37.1.9: Unaligned Time ID Listings

Time ID Values for DATE
Value
Index
dateFrequencyPercentage
1Tue, 28 Dec 194810.694444
2Tue, 18 Jan 194910.694444
3Tue, 8 Feb 194910.694444
4Tue, 1 Mar 194910.694444
5Tue, 22 Mar 194910.694444
6Tue, 12 Apr 194910.694444
7Tue, 3 May 194910.694444
8Tue, 24 May 194910.694444
9Fri, 17 Jun 194910.694444
10Tue, 5 Jul 194910.694444


Output 37.1.10: Unaligned Time ID Histogram

Unaligned Time ID Histogram


Last updated: November 05, 2018