Time Series Analysis Package

ACCUMULATE2 Method

  • rc = TSA.ACCUMULATE2 (time, y, 'interval', id, z, <'accumulate'>, <'setmiss'>, <'zeromiss'>);

The ACCUMULATE2 function accumulates a high-frequency time series to a lower frequency and expands the lower-frequency time series to the same length as the high-frequency series.

Required Arguments

You must specify the following arguments, separated by commas:

time

specifies the time ID array for the time series.

y

specifies the times series array to accumulate.

'interval'

specifies the time interval.

You can specify any valid time interval name as a quoted string. Here are some typical intervals:

DAY

specifies a seasonal cycle of length 7.

MONTH

specifies a seasonal cycle of length 12.

QTR

specifies a seasonal cycle of length 4.

YEAR

specifies a seasonal cycle of length 1.

See Chapter 4, Date Intervals, Formats, and Functions (SAS/ETS User's Guide), for other kinds of time intervals that you can specify.

Optional Arguments

You can also specify the following arguments, separated by commas. If you want to use a default value for any of these arguments, enter a space for it.

'accumulate'

specifies the accumulation statistic.

You can specify the following values within single quotation marks:

AVERAGE |AVG

specifies the average of the values in the time series.

CSS

specifies the corrected sum of squares of the values in the time series.

FIRST

specifies the first value of the time series.

LAST

specifies the last value of the time series.

MAXIMUM |MAX

specifies the maximum value in the time series.

MEDIAN |MED

specifies the median of the values in the time series.

MINIMUM |MIN

specifies the minimum value in the time series.

N

specifies the number of nonmissing observations.

NMISS

specifies the number of missing observations.

NOBS

specifies the number of observations.

STDDEV |STD

specifies the standard deviation of the values in the time series.

TOTAL

specifies the total sum of the values in the time series.

USS

specifies the uncorrected sum of squares of the values in the time series.

The default is TOTAL.

'setmiss'

specifies the missing value interpretation.

You can specify the following values within single quotation marks:

AVERAGE |AVG

specifies the accumulated average value.

FIRST

specifies the accumulated first nonmissing value.

LAST

specifies the accumulated last nonmissing value.

MAXIMUM |MAX

specifies the accumulated maximum value.

MEDIAN |MED

specifies the accumulated median value.

MINIMUM |MIN

specifies the accumulated minimum value.

MISSING

specifies a missing value.

NEXT

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

PREVIOUS |PREV

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

The default is MISSING.

'zeromiss'

specifies the zero value interpretation.

You can specify the following values within single quotation marks:

BOTH

sets both beginning and ending zeros to missing.

LEFT

sets beginning zeros to missing.

NONE

leaves beginning and ending zeros unchanged.

RIGHT

sets ending zeros to missing.

The default is NONE.

Returned Values

The ACCUMULATE2 function returns the following values:

rc

returns one of the following scalar return codes:

rc Termination Reason
0 Success.
< 0 Computational failure.

id

returns the time ID array for the accumulated time series.

z

returns the accumulated time series array.

Example

This example uses the TSMODEL procedure to accumulate a monthly time series into a yearly time series:

proc tsmodel data=mycas.air outarray=mycas.outarray;
   id date interval=month;
   var air;
   outarrays yearavg_expand yearid_expand;
   require tsa;
   submit;
   declare object TSA(tsa);
   rc=TSA.ACCUMULATE2(date, air, 'YEAR', yearid_expand, yearavg_expand,
                      'AVERAGE', , );
   endsubmit;
run;
Last updated: January 27, 2023