Working with Time Series Data

Interleaved Time Series

Normally, a time series data set has only one observation for each time period, or one observation for each time period within a cross section for a time series cross-sectional-form data set. However, it is sometimes useful to store several related time series in the same variable when the different series do not correspond to levels of a cross-sectional dimension of the data.

In this case, the different time series can be interleaved. An interleaved time series data set is similar to a time series cross-sectional data set, except that the observations are sorted differently, and the ID variable that distinguishes the different time series does not represent a cross-sectional dimension.

The interleaved time series form is a convenient way to store data when the results consist of several different kinds of time series for each of numerous independent variables. For example, the MODEL procedure, which can fit and simulate dynamic systems of equations, in which many inter-related endogenous variables evolve over time, produces an interleaved time series output data set. For each time period, the MODEL procedure output includes observations for the actual, predicted, and residual values for each of the endogenous variables. These observations are identified by values of the variable _TYPE_. The observations are interleaved in the output data set with observations for the same date grouped together.

Using Interleaved Data Sets as Input to SAS/ETS Procedures

Interleaved time series data sets are not directly accepted as input by SAS/ETS procedures. However, it is easy to use a WHERE statement with a DATA step or with any procedure to subset the input data and select one of the interleaved time series as the input. For example, to analyze the residual series contained in a PROC MODEL output data set using another SAS/ETS procedure, include a WHERE _TYPE_=’RESIDUAL’ statement. The following statements show how to extract the residuals from an output data set produced by PROC MODEL.

data residuals_only;
   set output_dataset;
   where _type_='RESIDUAL';
run;

Combined Cross Sections and Interleaved Time Series Data Sets

Interleaved time series output data sets produced from BY-group processing of time series cross-sectional input data sets have a complex structure that combines a cross-sectional dimension, a time dimension, and the values of the _TYPE_ variable.

Last updated: June 19, 2025