The TIMESERIES Procedure

ID Statement

  • ID variable INTERVAL=interval <options>;

The ID statement names a numeric variable that identifies observations in the input and output data sets. The ID variable’s values are assumed to be SAS date or datetime values. In addition, the ID statement specifies the (desired) frequency associated with the time series. The ID statement options also specify how the observations are accumulated and how the time ID values are aligned to form the time series. The information specified affects all variables listed in subsequent VAR statements. If the ID statement is specified, the INTERVAL= must also be used. If an ID statement is not specified, the observation number, with respect to the BY group, is used as the time ID.

The following options can be used with the ID statement:

ACCUMULATE= option

specifies how the data set observations are to be accumulated within each time period. The frequency (width of each time interval) is specified by the INTERVAL= option. The ID variable contains the time ID values. Each time ID variable value corresponds to a specific time period. The accumulated values form the time series, which is used in subsequent analysis.

The ACCUMULATE= option is useful when there are zero or more than one input observations that coincide with a particular time period (for example, time-stamped transactional data). The EXPAND procedure offers additional frequency conversions and transformations that can also be useful in creating a time series.

The following options determine how the observations are accumulated within each time period based on the ID variable and the frequency specified by the INTERVAL= option:

NONE

No accumulation occurs; the ID variable values must be equally spaced with respect to the frequency. This is the default option.

TOTAL

Observations are accumulated based on the total sum of their values.

AVERAGE | AVG

Observations are accumulated based on the average of their values.

MINIMUM | MIN

Observations are accumulated based on the minimum of their values.

MEDIAN | MED

Observations are accumulated based on the median of their values.

MAXIMUM | MAX

Observations are accumulated based on the maximum of their values.

N

Observations are accumulated based on the number of nonmissing observations.

NMISS

Observations are accumulated based on the number of missing observations.

NOBS

Observations are accumulated based on the number of observations.

FIRST

Observations are accumulated based on the first of their values.

LAST

Observations are accumulated based on the last of their values.

STDDEV |STD

Observations are accumulated based on the standard deviation of their values.

CSS

Observations are accumulated based on the corrected sum of squares of their values.

USS

Observations are accumulated based on the uncorrected sum of squares of their values.

If the ACCUMULATE= option is specified, the SETMISSING= option is useful for specifying how accumulated missing values are to be treated. If missing values should be interpreted as zero, then SETMISSING=0 should be used. The section Details: TIMESERIES Procedure describes accumulation in greater detail.

ALIGN= option

controls the alignment of SAS dates used to identify output observations. The ALIGN= option accepts the following values: BEGINNING | BEG | B, MIDDLE | MID | M, and ENDING | END | E. BEGINNING is the default.

BOUNDARYALIGN= option

controls how the ACCUMULATE= option is processed for the two boundary time intervals, which include the START= and END= time ID values. Some time ID values might fall inside the first and last accumulation intervals but fall outside the START= and END= boundaries. In these cases the BOUNDARYALIGN= option determines which values to include in the accumulation operation. You can specify the following options:

NONE

No values outside the START= and END= boundaries are accumulated.

START

All observations in the first time interval are accumulated.

END

All observations in the last time interval are accumulated.

BOTH

All observations in the first and last are accumulated.

If no option is specified, the default value BOUNDARYALIGN=NONE is used. The section Details: TIMESERIES Procedure describes the BOUNDARYALIGN= accumulation option in greater detail.

END= option

specifies a SAS date or datetime value that represents the end of the data. If the last time ID variable value is less than the END= value, the series is extended with missing values. If the last time ID variable value is greater than the END= value, the series is truncated. For example, END="&sysdate"D uses the automatic macro variable SYSDATE to extend or truncate the series to the current date. The START= and END= options can be used to ensure that data associated within each BY group contains the same number of observations.

FORMAT= format

specifies the SAS format for the time ID values. If the FORMAT= option is not specified, the default format is implied from the INTERVAL= option.

INTERVAL= interval

specifies the frequency of the accumulated time series. For example, if the input data set consists of quarterly observations, then INTERVAL=QTR should be used. If the PROC TIMESERIES statement SEASONALITY= option is not specified, the length of the seasonal cycle is implied from the INTERVAL= option. For example, INTERVAL=QTR implies a seasonal cycle of length 4. If the ACCUMULATE= option is also specified, the INTERVAL= option determines the time periods for the accumulation of observations. The INTERVAL= option is required and must be the first option specified in the ID statement.

NOTSORTED

specifies that the time ID values not be in sorted order. The TIMESERIES procedure sorts the data with respect to the time ID prior to analysis.

SETMISSING= option | number

specifies how missing values (either actual or accumulated) are to be interpreted in the accumulated time series. If a number is specified, missing values are set to the number. If a missing value indicates an unknown value, this option should not be used. If a missing value indicates no value, SETMISSING=0 should be used. You would typically use SETMISSING=0 for transactional data because no recorded data usually implies no activity. The following options can also be used to determine how missing values are assigned:

MISSING

Missing values are set to missing. This is the default option.

AVERAGE | AVG

Missing values are set to the accumulated average value.

MINIMUM | MIN

Missing values are set to the accumulated minimum value.

MEDIAN | MED

Missing values are set to the accumulated median value.

MAXIMUM | MAX

Missing values are set to the accumulated maximum value.

FIRST

Missing values are set to the accumulated first nonmissing value.

LAST

Missing values are set to the accumulated last nonmissing value.

PREVIOUS | PREV

Missing values are set to the previous period’s accumulated nonmissing value. Missing values at the beginning of the accumulated series remain missing.

NEXT

Missing values are set to the next period’s accumulated nonmissing value. Missing values at the end of the accumulated series remain missing.

START= option

specifies a SAS date or datetime value that represents the beginning of the data. If the first time ID variable value is greater than the START= value, the series is prepended with missing values. If the first time ID variable value is less than the START= value, the series is truncated. The START= and END= options can be used to ensure that data associated with each by group contains the same number of observations.