Chapter Contents |
Previous |
Next |

The EXPAND Procedure |

The operations that can be used in the TRANSFORMIN= and TRANSFORMOUT= options are shown in Table 11.1. Operations are applied to each value of the series. Each value of the series is replaced by the result of the operation.

In Table 11.1, *x*_{t} or *x* represents the value of the series
at a particular time period *t* before the transformation is applied,
*y*_{t} represents the value of the result series,
and N represents the total number of observations.

The notation [** n**] indicates that the argument

Syntax |
Result |

+ number | adds the specified number: x+number |

- number | subtracts the specified number: x-number |

* number | multiplies by the specified number: x*number |

& number | divides by the specified number: x & number |

ABS | absolute value: |x| |

[]
CD_I s | classical decomposition irregular component |

CD_S s | classical decomposition seasonal component |

CD_SA s | classical decomposition seasonally adjusted series |

CD_TC s | classical decomposition trend-cycle component |

CDA_I s | classical decomposition (additive) irregular component |

CDA_S s | classical decomposition (additive) seasonal component |

CDA_SA s | classical decomposition (additive) seasonally adjusted series |

CEIL | smallest integer greater than or equal to x: ceil(x) |

CMOVAVE window | centered moving average |

CMOVCSS window | centered moving corrected sum of squares |

CMOVMAX n | centered moving maximum |

CMOVMED n | centered moving median |

CMOVMIN n | centered moving minimum |

CMOVRANGE n | centered moving range |

CMOVSTD window | centered moving standard deviation |

CMOVSUM n | centered moving sum |

CMOVUSS window | centered moving uncorrected sum of squares |

CMOVVAR window | centered moving variance |

CUAVE []n | cumulative average |

CUCSS []n | cumulative corrected sum of squares |

CUMAX []n | cumulative maximum |

CUMED []n | cumulative median |

CUMIN []n | cumulative minimum |

CURANGE []n | cumulative range |

CUSTD []n | cumulative standard deviation |

CUSUM []n | moving sum |

CUUSS []n | cumulative uncorrected sum of squares |

CUVAR []n | cumulative variance |

DIF []n | lag n difference: x_{t}-x_{t-n} |

EWMA number | exponentially weighted moving average of x with |

smoothing weight number, where 0 < number < 1: | |

y_{t} = number x_{t} + (1-number) y_{t-1}. | |

This operation is also called simple exponential smoothing. | |

EXP | exponential function: exp(x) |

FLOOR | largest integer less than or equal to x:
floor(x) |

ILOGIT | inverse logistic function: [exp(x)/(1+exp(x))] |

LAG []n | value of the series n periods
earlier: x_{t-n} |

LEAD []n | value of the series n periods later:
x_{t+n} |

LOG | natural logarithm: log(x) |

LOGIT | logistic function: log([x/(1-x)]) |

MAX number | maximum of x and number: max(x,number) |

MIN number | minimum of x and number: min(x,number) |

> number | missing value if x <= number, else x |

>= number | missing value if x < number, else x |

= number | missing value if , else x |

= number | missing value if x = number, else x |

< number | missing value if x >= number, else x |

<= number | missing value if x > number, else x |

MOVAVE n | moving average of n neighboring values: |

MOVAVE(w ... _{1}w_{n}) | weighted moving average of neighboring values: |

MOVAVE window | backward moving average |

MOVCSS window | backward moving corrected sum of squares |

MOVMAX n | backward moving maximum |

MOVMED n | backward moving median |

MOVMIN n | backward moving minimum |

MOVRANGE n | backward moving range |

MOVSTD window | backward moving standard deviation |

MOVSUM n | backward moving sum |

MOVUSS window | backward moving uncorrected sum of squares |

MOVVAR window | backward moving variance |

MISSONLY <MEAN> | indicates that the following moving time window |

statistic operator should replace only missing values with the | |

moving statistic and should leave nonmissing values unchanged. | |

If the option MEAN is specified, then missing values are | |

replaced by the overall mean of the series. | |

NEG | changes the sign: -x |

NOMISS | indicates that the following moving time window |

statistic operator should not allow missing values. | |

RECIPROCAL | reciprocal: 1/x |

REVERSE | reverse the series: |

SETMISS number | replaces missing values in the series with the number specified. |

SIGN | -1, 0, or 1 as x is < 0, equals 0, or > 0 respectively |

SQRT | square root: |

SQUARE | square: x^{2} |

SUM | cumulative sum: |

SUM n | cumulative sum of n-period lags: |

x_{t}+x_{t-n}+x_{t-2n}+ ... | |

TRIM n | sets x_{t} to missing a value if or . |

TRIMLEFT n | sets x_{t} to missing a value if . |

TRIMRIGHT n | sets x_{t} to missing a value if . |

The centered moving time window operators are
CMOVAVE, CMOVCSS, CMOVMAX, CMOVMED, CMOVMIN, CMOVRANGE,
CMOVSTD, CMOVSUM, CMOVUSS, and CMOVVAR.
These operators compute statistics of the *n* values
*x*_{i} for observations .

The backward moving time window operators are
MOVAVE, MOVCSS, MOVMAX, MOVMED, MOVMIN, MOVRANGE,
MOVSTD, MOVSUM, MOVUSS, and MOVVAR.
These operators compute statistics of the *n* values
*x*_{t}, *x*_{t-1}, ... , *x*_{t-n+1}.

All the moving time window operators accept an argument *n*
specifying the number of periods to include in the time window.
For example, the following statement computes
a five-period backward moving average of X.

convert x=y / transformout=( movave 5 );

In this example, the final result is
*y*_{t} = (*x*_{t} + *x*_{t-1} + *x*_{t-2} + *x*_{t-3} + *x*_{t-4}) / 5.

The following statement computes a five-period centered moving average of X.

convert x=y / transformout=( cmovave 5 );

In this example, the final result is
*y*_{t} = (*x*_{t-2} + *x*_{t-1} + *x*_{t} + *x*_{t+1} + *x*_{t+2}/5.

If the window with a centered moving time window operator is not an
odd number, one more lagged value than lead value is included in the
time window.
For example, the result of the CMOVAVE 4 operator is
*y*_{t} = (*x*_{t-2} + *x*_{t-1} + *x*_{t} + *x*_{t+1})/4.

You can compute a forward moving time window operation by combining a backward moving time window operator with the REVERSE operator. For example, the following statement computes a five-period forward moving average of X.

convert x=y / transformout=( reverse movave 5 reverse );

In this example, the final result is
*y*_{t} = (*x*_{t} + *x*_{t+1} + *x*_{t+2} + *x*_{t+3} + *x*_{t+4})/5.

Some of the moving time window operators enable you to specify a list of weight values to compute weighted statistics. These are CMOVAVE, CMOVCSS, CMOVSTD, CMOVUSS, CMOVVAR, MOVAVE, MOVCSS, MOVSTD, MOVUSS, and MOVVAR.

To specify a weighted moving time window operator,
enter the weight values in parentheses after the operator name.
The window width *n* is equal to the number of weights that you specify;
do not specify *n*.

For example, the following statement computes a weighted five-period centered moving average of X.

convert x=y / transformout=( cmovave( .1 .2 .4 .2 .1 ) );

In this example, the final result is
*y*_{t} = .1 *x*_{t-2} + .2 *x*_{t-1} + .4 *x*_{t} + .2 *x*_{t+1} + .1 *x*_{t+2}.

The weight values must be greater than zero. If the weights do not sum to 1, the weights specified are divided by their sum to produce the weights used to compute the statistic.

At the beginning of the series, and at the end of the series for the centered operators, a complete time window is not available. The computation of the moving time window operators is adjusted for these boundary conditions as follows.

For backward moving window operators, the width of the time window is shortened at the beginning of the series. For example, the results of the MOVSUM 3 operator are

For centered moving window operators, the width of the time window is shortened at both the beginning and the end of the series. When an observation is unavailable at one side of the moving time window, the corresponding observation at the other side of the window is ignored. For example, the results of the CMOVSUM 5 operator are

For weighted moving time window operators, the weights for the unavailable or unused observations are ignored and the remaining weights renormalized to sum to 1.

By default, the cumulative statistics operators compute the
statistics from all previous values of the series,
so that *y*_{t} is based on the set of values
*x _{1}*,

convert x=y / transformout=( cusum );

You can also specify a lag increment argument *n* for the
cumulative statistics operators.
In this case, the statistic is computed from the current and
every *n*^{th} previous value.
For example, the following statement computes *y*_{t} as
the cumulative sum of nonmissing *x*_{i} values for
odd *i* when *t* is odd and for even *i* when *t* is even.

convert x=y / transformout=( cusum 2 );

The results of this example are

You can use these functions to trim the results of moving time window operators so that the result series contains only values computed from a full width time window. For example, the following statements compute a centered five-period moving average of X, and they set to missing values at the ends of the series that are averages of fewer than five values.

convert x=y / transformout=( movave 5 trim 2 );

Normally, the moving time window and cumulative statistics operators ignore missing values and compute their results for the nonmissing values. When preceded by the NOMISS operator, these functions produce a missing result if any value within the time window is missing. The NOMISS operator does not perform any calculations, but serves to modify the operation of the moving time window operator that follows it. The NOMISS operator has no effect unless it is followed by a moving time window operator.

For example, the following statement computes a five-period moving average of the variable X but produces a missing value when any of the five values are missing.

convert x=y / transformout=( nomiss movave 5 );

The following statement computes the cumulative sum of the variable X but produces a missing value for all periods after the first missing X value.

convert x=y / transformout=( nomiss cusum );

Similar to the NOMISS operator, the MISSONLY operator does not perform any calculations (unless followed by the MEAN option), but it serves to modify the operation of the moving time window operator that follows it. When preceded by the MISSONLY operator, these moving time window operators replace any missing values with the moving statistic and leave nonmissing values unchanged.

For example, the following statement replaces any missing values of the variable X with an exponentially weighted moving average of the past values of X and leaves nonmissing values unchanged. The missing values are then interpolated using an exponentially weighted moving average or simple exponential smoothing.

convert x=y / transformout=( missonly ewma 0.3 );

For example, the following statement replaces any missing values of the variable X with the overall mean of X.

convert x=y / transformout=( missonly mean );

You can use the SETMISS operator to replace missing values with a specified number. For example, the following statement replaces any missing values of the variable X with the number 8.77.

convert x=y / transformout=( setmiss 8.77 );

*TC*_{t}- is the trend-cycle component.
*S*_{t}- is the seasonal component or seasonal factors
that are periodic with period $s$ and with mean
one (multiplicative) or zero (additive).
*I*_{t}- is the irregular or random component that is assumed to have mean one (multiplicative) or zero (additive).

The CD_TC operator computes the trend-cycle component for both the multiplicative and additive models. When

In the case

convert x=tc / transformout=( cmovave 5 trim 2 );

When

In the case

convert x=tc / transformout=(cmovave 12 movave 2 trim 6);

The CD_S and CDA_S operators compute the seasonal components for the multiplicative and additive models, respectively. First, the trend-cycle component is computed as shown previously. Second, the seasonal-irregular component is computed by

The CD_I and CDA_I operators compute the irregular component for the multiplicative and additive models respectively. First, the seasonal component is computed as shown previously. Next, the irregular component is determined from the seasonal-irregular and seasonal components as appropriate.

The CD_SA and CDA_SA operators compute the seasonally adjusted time series for the multiplicative and additive models, respectively. After decomposition, the original time series can be seasonally adjusted as appropriate.

The following statements compute all the multiplicative
classical decomposition components for the variable X for *s*=12.

convert x=tc / transformout=( cd_tc 12 ); convert x=s / transformout=( cd_s 12 ); convert x=i / transformout=( cd_i 12 ); convert x=sa / transformout=( cd_sa 12 );

The following statements compute all the additive
classical decomposition components for the variable X for *s*=4.

convert x=tc / transformout=( cd_tc 4 ); convert x=s / transformout=( cda_s 4 ); convert x=i / transformout=( cda_i 4 ); convert x=sa / transformout=( cda_sa 4 );

Chapter Contents |
Previous |
Next |
Top |

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.