CESM Procedure
ID Statement
ID variable INTERVAL=interval < options > ;
The ID statement names a numeric variable that identifies observations in the input and output data tables. The values of the ID variable are assumed to be SAS date or datetime values. In addition, the ID statement specifies (in the INTERVAL= option) the frequency that is associated with the time series. The options also specify how to accumulate the observations and how to align the time ID values to form the time series to be forecast. The specified information affects all variables that are specified in subsequent FORECAST statements. If an ID statement is not specified, the observation number (with respect to the BY group) is used as the time ID.
You must specify the following argument:
- INTERVAL=interval
-
specifies the frequency of the input time series or of the time series to be accumulated from the input data. For example, if the input data table consists of quarterly observations, then INTERVAL=QTR should be used. If the SEASONALITY= option is not specified, the length of the seasonal cycle is implied by 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 basic intervals are YEAR, SEMIYEAR, QTR, MONTH, SEMIMONTH, TENDAY, WEEK, WEEKDAY, DAY, HOUR, MINUTE, and SECOND. For more information about the intervals that can be specified, see the chapter "Date Intervals, Formats, and Functions" in SAS/ETS User's Guide.
You can also specify the following options:
- ACCUMULATE=option
-
specifies how to accumulate the data table observations within each time period. The frequency (width of each time interval) is specified in the INTERVAL= option. The ID variable contains the time ID values. Each value of the time ID variable value corresponds to a specific time period. The accumulated values form the time series, which is used in subsequent model fitting and forecasting.
The ACCUMULATE= option is particularly useful when there are gaps in the input data or when there are multiple input observations that coincide with a particular time period (for example, transactional data). The EXPAND procedure in SAS/ETS User's Guide offers additional frequency conversions and transformations that can also be useful in creating a time series.
You can specify the following options to determine how to accumulate the observations within each time period based on the ID variable and the frequency that is specified in the INTERVAL= option:
- TOTAL | SUM
accumulates observations based on the total sum of their values.
- AVERAGE | AVG
accumulates observations based on the average of their values.
- MINIMUM | MIN
accumulates observations based on the minimum of their values.
- MAXIMUM | MAX
accumulates observations based on the maximum of their values.
- N
accumulates observations based on the number of nonmissing observations.
- NMISS
accumulates observations based on the number of missing observations.
- STDDEV | STD
accumulates observations based on the standard deviation of their values.
- CSS
accumulates observations based on the corrected sum of squares of their values.
- USS
accumulates observations based on the uncorrected sum of squares of their values.
By default, ACCUMULATE=TOTAL.
If the ACCUMULATE= option is specified, the SETMISSING= option is useful for specifying how to treat accumulated missing values. If missing values should be interpreted as 0, then you should specify SETMISSING=0. For more information about accumulation, see the section Accumulation.
- ALIGN=option
-
controls the alignment of SAS date or datetime values that are used to identify the time period of output observations. Although any date or datetime value within the time period can identify the time period, this option requests that the representative date or datetime for the time period be calculated as the beginning date or datetime of the time period, the ending date or datetime of the time period, or the middle date or datetime of the time period. In addition to aligning the time ID values consistently for observations that are supplied by the user, this option specifies the method for calculating the time ID values for observations in the forecast and backcast time periods, which often are not supplied by the user. You can specify the following options:
- BEGINNING | BEG | B
represents each time period by using the beginning SAS date or datetime value of the time period.
- ENDING | END | E
represents each time period by using the ending SAS date or datetime value of the time period.
- MIDDLE | MID | M
represents each time period by using the middle SAS date or datetime value of the time period. The middle is calculated as the average of the beginning and ending values.
By default, ALIGN=BEGINNING.
- END=date | datetime
specifies a SAS date or datetime literal value that represents the end of the data. If the value of the last time ID variable is less than the END= value, the series is extended with missing values. If the value of the last time ID variable is greater than the END= value, the series is truncated. For example,
END='1jan2008'Drequests that data for time periods after the first of January 2008 not be used. The optionEND="&sysdate"Duses the automatic macro variableSYSDATEto extend or truncate the series to the current date. You can use this option and the START= option to ensure that data that are associated with each BY group contain 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 by the INTERVAL= option.
- SETMISSING=n | option
-
specifies how to interpret missing values (either actual or accumulated) in the accumulated time series. You can specify either a number (n) or an option to determine how to interpret missing values:
- n
interprets a missing value as having the value n. You can specify any number for n, but not a missing value. If a missing value indicates a 0 value, specify SETMISSING=0. You typically use SETMISSING=0 for transactional data because no recorded data usually implies no activity.
- MISSING
interprets a missing value as a missing value. Use this option if a missing value indicates an unknown value.
- AVERAGE | AVG
interprets a missing value as the average value of all accumulated nonmissing values in the span of the series.
- MINIMUM | MIN
interprets a missing value as the minimum value of all accumulated nonmissing values in the span of the series.
- MEDIAN | MED
interprets a missing value as the median value of all accumulated nonmissing values in the span of the series.
- MAXIMUM | MAX
interprets a missing value as the maximum value of all accumulated nonmissing values in the span of the series.
- FIRST
interprets a missing value as the first nonmissing value of all accumulated nonmissing values in the span of the series.
- LAST
interprets a missing value as the last nonmissing value of all accumulated nonmissing values in the span of the series.
- PREVIOUS | PREV
interprets a missing value as the previous period’s accumulated nonmissing value. Missing values at the beginning of the accumulated series remain missing.
- NEXT
interprets a missing value as the next period’s accumulated nonmissing value. Missing values at the end of the accumulated series remain missing.
By default, SETMISSING=MISSING.
- START=date | datetime
specifies a SAS date or datetime literal value that represents the beginning of the data. If the value of the first time ID variable is greater than the START= value, the series is prefixed with missing values. If the value of the first time ID variable is less than the START= value, the series is truncated. You can use this option and the END= option to ensure that data that are associated with each BY group contain the same number of observations.
- TRIMID=method
-
specifies the method for trimming the data in the BY groups. The output time ID variable span that is calculated by the method is dependent on the input time ID variable span, irrespective of missing values of the time series variables. Depending on the method and the input time ID variable data, leading or trailing missing values can be added to the time series variables.
After the output time ID variable span is calculated by the method, the ending value of the output time ID variable is recalculated according to the value of the LEAD= option in the FORECAST statement (if the LEAD= option is specified).
You can specify one of the following methods:
- NONE
uses the same starting and ending values of the output time ID variable for all BY groups. The span of the output time ID variable includes all values that are input as a time ID value for all BY groups. The time series variables are extended with leading or trailing missing values as required.
- LEFT
uses the identifying date for the first time period that is input for the BY group as the starting value of the output time ID variable for each BY group. The time series values in each BY group are not extended with leading missing values. The ending value of the time ID variable is the same for all BY groups. The time series variables are extended with trailing missing values as required.
- RIGHT
uses the identifying date for the last time period that is input for the BY group as the ending value of the output time ID variable for each BY group. The time series values in each BY group are not extended with trailing missing values. The starting value of the time ID variable is the same for all BY groups. The time series variables are extended with leading missing values as required.
- BOTH
uses the span of the input time ID variable for the BY group as the span of the output time ID variable for each BY group. The time series values in each BY group are not extended with leading or trailing missing values.
By default, TRIMID=NONE.