EXPAND Procedure

Transformation Operations

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

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

The notation n Subscript normal o normal p normal t normal i normal o normal n normal a normal l indicates that the argument n Subscript normal o normal p normal t normal i normal o normal n normal a normal l is an optional integer; the default is 1. The notation window is used as the argument for the moving statistics operators, and it indicates that you can specify either a number of periods n (where n is an integer) or a list of n weights in parentheses. The internal maximum value of the number of periods n is clipped at the number of observations in the series. The notation sequence is used as the argument for the sequence operators, and it indicates that you must specify a sequence of numbers. The notation s indicates the length of seasonality, and it is a required argument.

Table 2: Transformation Operations

Syntax Result
+ number Adds the specified number : x plus n u m b e r
minus number Subtracts the specified number : x minus n u m b e r
* number Multiplies by the specified number : x asterisk n u m b e r
/ number Divides by the specified number : x slash n u m b e r
ABS Absolute value: StartAbsoluteValue x EndAbsoluteValue
ADJUST Indicates that the following moving window summation or product operator should be adjusted for window width
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 : normal c normal e normal i normal l left-parenthesis x right-parenthesis
CMOVAVE window Centered moving average
CMOVCSS window Centered moving corrected sum of squares
CMOVGMEAN window Centered moving geometric mean
for window = number of periods, n:
left-parenthesis product Underscript j equals j Subscript normal m normal i normal n Baseline Overscript j Subscript normal m normal a normal x Baseline Endscripts x Subscript t plus j Baseline right-parenthesis Superscript 1 slash n
j Subscript normal m normal i normal n Baseline equals minus left-parenthesis n plus n mod 2 right-parenthesis slash 2 plus 1
j Subscript normal m normal a normal x Baseline equals left-parenthesis n minus n mod 2 right-parenthesis slash 2
for window = weight list, w:
left-parenthesis product Underscript j equals j Subscript normal m normal i normal n Baseline Overscript j Subscript normal m normal a normal x Baseline Endscripts x Subscript t plus j Superscript w Super Subscript j minus j Super Sub Subscript normal m normal i normal n Super Subscript Superscript Baseline right-parenthesis Superscript 1 slash sigma-summation Underscript j equals 0 Overscript n minus 1 Endscripts w Super Subscript j
CMOVMAX n Centered moving maximum
CMOVMED n Centered moving median
CMOVMIN n Centered moving minimum
CMOVPROD window Centered moving product
for window = number of periods, n:
product Underscript j equals j Subscript normal m normal i normal n Baseline Overscript j Subscript normal m normal a normal x Endscripts x Subscript t plus j
for window = weight list, w:
left-parenthesis product Underscript j equals j Subscript normal m normal i normal n Baseline Overscript j Subscript normal m normal a normal x Baseline Endscripts x Subscript t plus j Superscript w Super Subscript j minus j Super Sub Subscript normal m normal i normal n Super Subscript Superscript Baseline right-parenthesis Superscript 1 slash sigma-summation Underscript j equals 0 Overscript n minus 1 Endscripts w Super Subscript j
CMOVRANGE n Centered moving range
CMOVRANK n Centered moving rank
CMOVSTD window Centered moving standard deviation
CMOVSUM n Centered moving sum
CMOVTVALUE window Centered moving t value
CMOVUSS window Centered moving uncorrected sum of squares
CMOVVAR window Centered moving variance
CUAVE n Subscript normal o normal p normal t normal i normal o normal n normal a normal l Cumulative average
CUCSS n Subscript normal o normal p normal t normal i normal o normal n normal a normal l Cumulative corrected sum of squares
CUGMEAN n Subscript normal o normal p normal t normal i normal o normal n normal a normal l Cumulative geometric mean
CUMAX n Subscript normal o normal p normal t normal i normal o normal n normal a normal l Cumulative maximum
CUMED n Subscript normal o normal p normal t normal i normal o normal n normal a normal l Cumulative median
CUMIN n Subscript normal o normal p normal t normal i normal o normal n normal a normal l Cumulative minimum
CUPROD n Subscript normal o normal p normal t normal i normal o normal n normal a normal l Cumulative product
CURANK n Subscript normal o normal p normal t normal i normal o normal n normal a normal l Cumulative rank
CURANGE n Subscript normal o normal p normal t normal i normal o normal n normal a normal l Cumulative range
CUSTD n Subscript normal o normal p normal t normal i normal o normal n normal a normal l Cumulative standard deviation
CUSUM n Subscript normal o normal p normal t normal i normal o normal n normal a normal l Cumulative sum
CUTVALUE n Subscript normal o normal p normal t normal i normal o normal n normal a normal l Cumulative t value
CUUSS n Subscript normal o normal p normal t normal i normal o normal n normal a normal l Cumulative uncorrected sum of squares
CUVAR n Subscript normal o normal p normal t normal i normal o normal n normal a normal l Cumulative variance
DIF n Subscript normal o normal p normal t normal i normal o normal n normal a normal l Span n difference: x Subscript t Baseline minus x Subscript t minus n
EWMA number Exponentially weighted moving average of x with
smoothing weight number, where 0 less-than n u m b e r less-than 1:
y Subscript t Baseline equals n u m b e r x Subscript t Baseline plus left-parenthesis 1 minus n u m b e r right-parenthesis y Subscript t minus 1 Baseline.
This operation is also called simple exponential smoothing.
EXP Exponential function: exp left-parenthesis x right-parenthesis
FDIF d Fractional difference with difference order d where 0 less-than d less-than 0.5
FLOOR Largest integer less than or equal to x : normal f normal l normal o normal o normal r left-parenthesis x right-parenthesis
FSUM d Fractional summation with summation order d where 0 less-than d less-than 0.5
HP_T lambda Hodrick-Prescott Filter trend component where lambda is the nonnegative filter parameter
HP_C lambda Hodrick-Prescott Filter cycle component where lambda is the nonnegative filter parameter
ILOGIT Inverse logistic function: StartFraction exp left-parenthesis x right-parenthesis Over 1 plus exp left-parenthesis x right-parenthesis EndFraction
LAG n Subscript normal o normal p normal t normal i normal o normal n normal a normal l Value of the series n periods earlier: x Subscript t minus n
LEAD n Subscript normal o normal p normal t normal i normal o normal n normal a normal l Value of the series n periods later: x Subscript t plus n
LOG Natural logarithm: log left-parenthesis x right-parenthesis
LOGIT Logistic function: log left-parenthesis StartFraction x Over 1 minus x EndFraction right-parenthesis
MAX number Maximum of x and number : max left-parenthesis x comma italic number right-parenthesis
MIN number Minimum of x and number : min left-parenthesis x comma italic number right-parenthesis
> number Missing value if x less-than equals italic number, else x
>= number Missing value if x less-than italic number, else x
= number Missing value if x not-equals italic number, else x
logical-and= number Missing value if x equals italic number, else x
< number Missing value if x greater-than equals italic number, else x
<= number Missing value if x greater-than italic number, else x
MOVAVE n Backward moving average of n neighboring values:
StartFraction 1 Over n EndFraction sigma-summation Underscript j equals 0 Overscript n minus 1 Endscripts x Subscript t minus j
MOVAVE window Backward weighted moving average of neighboring values:
left-parenthesis sigma-summation Underscript j equals 1 Overscript n Endscripts w Subscript j Baseline x Subscript t minus n plus j Baseline right-parenthesis slash left-parenthesis sigma-summation Underscript j equals 1 Overscript n Endscripts w Subscript j Baseline right-parenthesis
MOVCSS window Backward moving corrected sum of squares
MOVGMEAN window Backward moving geometric mean
for window = number of periods, n:
left-parenthesis product Underscript j equals 1 Overscript n Endscripts x Subscript t minus n plus j Baseline right-parenthesis Superscript 1 slash n
for window = weight list, w:
left-parenthesis product Underscript j equals 1 Overscript n Endscripts x Subscript t minus n plus j Superscript w Super Subscript j Superscript Baseline right-parenthesis Superscript 1 slash sigma-summation Underscript j equals 1 Overscript n Endscripts w Super Subscript j
MOVMAX n Backward moving maximum
MOVMED n Backward moving median
MOVMIN n Backward moving minimum
MOVPROD window Backward moving product
for window = number of periods, n:
product Underscript j equals 1 Overscript n Endscripts x Subscript t minus n plus j
for window = weight list, w:
left-parenthesis product Underscript j equals 1 Overscript n Endscripts x Subscript t minus n plus j Superscript w Super Subscript j Superscript Baseline right-parenthesis Superscript 1 slash sigma-summation Underscript j equals 1 Overscript n Endscripts w Super Subscript j
MOVRANGE n Backward moving range
MOVRANK n Backward moving rank
MOVSTD window Backward moving weighted standard deviation:
StartRoot StartFraction 1 Over n minus 1 EndFraction sigma-summation Underscript j equals 1 Overscript n Endscripts w Subscript i Baseline left-parenthesis x Subscript j Baseline minus x overbar Subscript w Baseline right-parenthesis squared EndRoot
MOVSUM n Backward moving sum
MOVTVALUE window Backward moving t value
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: negative x
NOMISS Indicates that the following moving time window
statistic operator should not allow missing values
PCTDIF n Percent difference of the current value and lag n
PCTSUM n Percent summation of the current value and cumulative sum n-lag periods
RATIO n Ratio of current value to lag n
RECIPROCAL Reciprocal: 1 slash x
REVERSE Reverses the series: x Subscript Sub Subscript upper N minus t
SCALE n 1 n 2 Scales the series between n 1 and n 2
SEQADD sequence Adds sequence values to series
SEQDIV sequence Divides the series by sequence values
SEQMINUS sequence Subtracts sequence values to series
SEQMULT sequence Multiplies the series by sequence values
SET (n 1 n 2) Sets all values of n 1 to n 2
SETEMBEDDED (n 1 n 2) Sets embedded values of n 1 to n 2
SETLEFT (n 1 n 2) Sets beginning values of n 1 to n 2
SETMISS number Replaces missing values in the series with the number specified
SETRIGHT (n 1 n 2) Sets ending values of n 1 to n 2
SIGN negative 1, 0, or 1 as x is < 0, equals 0, or > 0, respectively
SQRT Square root: StartRoot x EndRoot
SQUARE Square: x squared
SUM Cumulative sum: sigma-summation Underscript j equals 1 Overscript t Endscripts x Subscript j
SUM n Cumulative sum of multiples of n-period lags:
x Subscript t Baseline plus x Subscript t minus n Baseline plus x Subscript t minus 2 n Baseline plus midline-horizontal-ellipsis
TRIM n Sets x Subscript t to missing a value if t less-than-or-equal-to n or t greater-than-or-equal-to upper N minus n plus 1
TRIMLEFT n Sets x Subscript t to missing a value if t less-than-or-equal-to n
TRIMRIGHT n Sets x Subscript t to missing a value if t greater-than-or-equal-to upper N minus n plus 1


Moving Time Window Operators

Some operators compute statistics for a set of values within a moving time window; these are called moving time window operators. There are centered and backward versions of these operators.

The centered moving time window operators are CMOVAVE, CMOVCSS, CMOVGMEAN, CMOVMAX, CMOVMED, CMOVMIN, CMOVPROD, CMOVRANGE, CMOVRANK, CMOVSTD, CMOVSUM, CMOVTVALUE, CMOVUSS, and CMOVVAR. These operators compute statistics of the n values x Subscript i for observations t minus left-parenthesis n plus n mod 2 right-parenthesis slash 2 plus 1 less-than-or-equal-to i less-than-or-equal-to t plus left-parenthesis n minus n mod 2 right-parenthesis slash 2

The backward moving time window operators are MOVAVE, MOVCSS, MOVGMEAN, MOVMAX, MOVMED, MOVMIN, MOVPROD, MOVRANGE, MOVRANK, MOVSTD, MOVSUM, MOVTVALUE, MOVUSS, and MOVVAR. These operators compute statistics of the n values x Subscript t Baseline comma x Subscript t minus 1 Baseline comma ellipsis comma x Subscript t minus n plus 1 Baseline.

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 resulting transformation is

y Subscript t Baseline equals left-parenthesis x Subscript t Baseline plus x Subscript t minus 1 Baseline plus x Subscript t minus 2 Baseline plus x Subscript t minus 3 Baseline plus x Subscript t minus 4 Baseline right-parenthesis slash 5

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

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

In this example, the resulting transformation is

y Subscript t Baseline equals left-parenthesis x Subscript t minus 2 Baseline plus x Subscript t minus 1 Baseline plus x Subscript t Baseline plus x Subscript t plus 1 Baseline plus x Subscript t plus 2 Baseline right-parenthesis slash 5

If the window with a centered moving time window operator is not an odd number, one more lead value than lag value is included in the time window. For example, the result of the CMOVAVE 4 operator is

y Subscript t Baseline equals left-parenthesis x Subscript t minus 1 Baseline plus x Subscript t Baseline plus x Subscript t plus 1 Baseline plus x Subscript t plus 2 Baseline right-parenthesis slash 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 resulting transformation is

y Subscript t Baseline equals left-parenthesis x Subscript t Baseline plus x Subscript t plus 1 Baseline plus x Subscript t plus 2 Baseline plus x Subscript t plus 3 Baseline plus x Subscript t plus 4 Baseline right-parenthesis slash 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, CMOVGMEAN, CMOVPROD, CMOVSTD, CMOVTVALUE, CMOVUSS, CMOVVAR, MOVAVE, MOVCSS, MOVGMEAN, MOVPROD, MOVSTD, MOVTVALUE, 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 resulting transformation is

y Subscript t Baseline equals .1 x Subscript t minus 2 Baseline plus .2 x Subscript t minus 1 Baseline plus .4 x Subscript t Baseline plus .2 x Subscript t plus 1 Baseline plus .1 x Subscript t plus 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.

A complete time window is not available at the beginning of the series. For the centered operators a complete window is also not available at the end of the series. 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

StartLayout 1st Row 1st Column y 1 2nd Column equals 3rd Column x 1 2nd Row 1st Column y 2 2nd Column equals 3rd Column x 1 plus x 2 3rd Row 1st Column y 3 2nd Column equals 3rd Column x 1 plus x 2 plus x 3 4th Row 1st Column y 4 2nd Column equals 3rd Column x 2 plus x 3 plus x 4 5th Row 1st Column y 5 2nd Column equals 3rd Column x 3 plus x 4 plus x 5 6th Row 1st Column Blank 2nd Column midline-horizontal-ellipsis 3rd Column Blank EndLayout

For centered moving window operators, the width of the time window is shortened at the beginning and the end of the series due to unavailable observations. For example, the results of the CMOVSUM 5 operator are

StartLayout 1st Row 1st Column y 1 2nd Column equals 3rd Column x 1 plus x 2 plus x 3 2nd Row 1st Column y 2 2nd Column equals 3rd Column x 1 plus x 2 plus x 3 plus x 4 3rd Row 1st Column y 3 2nd Column equals 3rd Column x 1 plus x 2 plus x 3 plus x 4 plus x 5 4th Row 1st Column y 4 2nd Column equals 3rd Column x 2 plus x 3 plus x 4 plus x 5 plus x 6 5th Row 1st Column Blank 2nd Column midline-horizontal-ellipsis 3rd Column Blank 6th Row 1st Column y Subscript Sub Subscript upper N minus 2 2nd Column equals 3rd Column x Subscript Sub Subscript upper N minus 4 Baseline plus x Subscript Sub Subscript upper N minus 3 Baseline plus x Subscript Sub Subscript upper N minus 2 Baseline plus x Subscript Sub Subscript upper N minus 1 Baseline plus x Subscript Sub Subscript upper N 7th Row 1st Column y Subscript Sub Subscript upper N minus 1 2nd Column equals 3rd Column x Subscript Sub Subscript upper N minus 3 Baseline plus x Subscript Sub Subscript upper N minus 2 Baseline plus x Subscript Sub Subscript upper N minus 1 Baseline plus x Subscript Sub Subscript upper N 8th Row 1st Column y Subscript Sub Subscript upper N 2nd Column equals 3rd Column x Subscript Sub Subscript upper N minus 2 Baseline plus x Subscript Sub Subscript upper N minus 1 Baseline plus x Subscript Sub Subscript upper N EndLayout

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.

Cumulative Statistics Operators

Some operators compute cumulative statistics for a set of current and previous values of the series. The cumulative statistics operators are CUAVE, CUCSS, CUMAX, CUMED, CUMIN, CURANGE, CUSTD, CUSUM, CUUSS, and CUVAR.

By default, the cumulative statistics operators compute the statistics from all previous values of the series, so that y Subscript t is based on the set of values x Subscript t Baseline comma x Subscript t minus 1 Baseline comma ellipsis comma x 1. For example, the following statement computes y Subscript t as the cumulative sum of nonmissing x Subscript i values for i less-than-or-equal-to t:

convert x=y / transformout=( cusum );

You can specify a lag increment argument n for the cumulative statistics operators. In this case, the statistic is computed from the current and every nth previous value. When n is specified these operators compute statistics of the values x Subscript t Baseline comma x Subscript t minus n Baseline comma x Subscript t minus 2 n Baseline comma ellipsis comma x Subscript t minus i n Baseline for t minus i n greater-than 0.

For example, the following statement computes y Subscript t as the cumulative sum of nonmissing x Subscript 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

StartLayout 1st Row 1st Column y 1 2nd Column equals 3rd Column x 1 2nd Row 1st Column y 2 2nd Column equals 3rd Column x 2 3rd Row 1st Column y 3 2nd Column equals 3rd Column x 1 plus x 3 4th Row 1st Column y 4 2nd Column equals 3rd Column x 2 plus x 4 5th Row 1st Column y 5 2nd Column equals 3rd Column x 1 plus x 3 plus x 5 6th Row 1st Column y 6 2nd Column equals 3rd Column x 2 plus x 4 plus x 6 7th Row 1st Column Blank 2nd Column midline-horizontal-ellipsis 3rd Column Blank EndLayout

Missing Values

You can truncate the length of the result series by using the TRIM, TRIMLEFT, and TRIMRIGHT operators to set values to missing at the beginning or end of the series.

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=( cmovave 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 interpolated using the specified exponentially weighted moving average. (This is also called simple exponential smoothing.)

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

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 );

Classical Decomposition Operators

If x Subscript t is a seasonal time series with s observations per season, classical decomposition methods "break down" the time series into four components: trend, cycle, seasonal, and irregular components. The trend and cycle components are often combined to form the trend-cycle component. There are two basic forms of classical decomposition: multiplicative and additive, which are show below.

StartLayout 1st Row 1st Column x Subscript t 2nd Column equals 3rd Column upper T upper C Subscript t Baseline upper S Subscript t Baseline upper I Subscript t 2nd Row 1st Column x Subscript t 2nd Column equals 3rd Column upper T upper C Subscript t plus upper S Subscript t Baseline plus upper I Subscript t EndLayout

where

upper T upper C Subscript t

is the trend-cycle component

upper S Subscript t

is the seasonal component or seasonal factors that are periodic with period s and with mean one (multiplicative) or zero (additive)

upper I Subscript t

is the irregular or random component that is assumed to have mean one (multiplicative) or zero (additive)

For multiplicative decomposition, all of the x Subscript t values should be positive.

The CD_TC operator computes the trend-cycle component for both the multiplicative and additive models. When s is odd, this operator computes an s-period centered moving average as follows:

upper T upper C Subscript t Baseline equals sigma-summation Underscript k equals minus left floor s slash 2 right floor Overscript left floor s slash 2 right floor Endscripts x Subscript t plus k Baseline slash s

For example, in the case where s=5, the CD_TC s operator

convert x=tc / transformout=( cd_tc 5 );

is equivalent to the following CMOVAVE operator:

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

When s is even, the CD_TC s operator computes the average of two adjacent s-period centered moving averages as follows:

upper T upper C Subscript t Baseline equals sigma-summation Underscript k equals minus left floor s slash 2 right floor Overscript left floor s slash 2 right floor minus 1 Endscripts left-parenthesis x Subscript t plus k Baseline plus x Subscript t plus 1 plus k Baseline right-parenthesis slash 2 s

For example, in the case where s=12, the CD_TC s operator

convert x=tc / transformout=( cd_tc 12 );

is equivalent to the following CMOVAVE operator:

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 upper S upper I Subscript t Baseline equals x Subscript t Baseline slash upper T upper C Subscript t for the multiplicative model and by upper S upper I Subscript t Baseline equals x Subscript t Baseline minus upper T upper C Subscript t for the additive model. The seasonal component is obtained by averaging the seasonal-irregular component for each season.

upper S Subscript k plus j s Baseline equals sigma-summation Underscript t equals k mod s Endscripts StartFraction upper S upper I Subscript t Baseline Over n slash s EndFraction

where 0 less-than-or-equal-to j less-than-or-equal-to n slash s and 1 less-than-or-equal-to k less-than-or-equal-to s. The seasonal components are normalized to sum to one (multiplicative) or zero (additive).

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.

StartLayout 1st Row 1st Column upper I Subscript t 2nd Column equals 3rd Column upper S upper I Subscript t slash upper S Subscript t 2nd Row 1st Column upper I Subscript t 2nd Column equals 3rd Column upper S upper I Subscript t minus upper S Subscript t EndLayout

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.

StartLayout 1st Row 1st Column x overTilde Subscript t 2nd Column equals 3rd Column x Subscript t Baseline slash upper S Subscript t Baseline equals upper T upper C Subscript t Baseline upper I Subscript t Baseline 2nd Row 1st Column x overTilde Subscript t 2nd Column equals 3rd Column x Subscript t Baseline minus upper S Subscript t Baseline equals upper T upper C Subscript t Baseline plus upper I Subscript t EndLayout

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 );

The X12 and X11 procedures provide other methods for seasonal decomposition. See Chapter 44, X12 Procedure, and Chapter 43, X11 Procedure.

Fractional Operators

For fractional operators, the parameter, d, represents the order of fractional differencing. Fractional summation is the inverse operation of fractional differencing.

Examples of Usage

Suppose that X is a fractionally integrated time series variable of order d=0.25. Fractionally differencing X forms a time series variable Y, which is not integrated.

convert x=y / transformout=(fdif 0.25);

Suppose that Z is a non-integrated time series variable. Fractionally summing Z forms a time series W, which is fractionally integrated of order d equals 0.25.

convert z=w / transformout=(fsum 0.25);

Moving Rank Operators

For the rank operators, the ranks are computed based on the current value with respect to the cumulative, centered, or moving window values. If the current value is missing, the transformed current value is set to missing. If the NOMISS option was previously specified and if any missing values are present in the moving window, the transformed current value is set to missing. Otherwise, redundant values from the moving window are removed and the rank of the current value is computed among the unique values of the moving window.

Examples of Usage

The trades of a particular security are recorded for each weekday in a variable named PRICE. Given the historical daily trades, the ranking of the price of this security for each trading day, considering its entire past history, can be computed as follows:

convert price=history / transformout=( curank );

The ranking of the price of this security for each trading day considering the previous week’s history can be computed as follows:

convert price=lastweek / transformout=( movrank 5 );

The ranking of the price of this security for each trading day considering the previous two week’s history can be computed as follows:

convert price=twoweek / transformout=( movrank 10 );

Moving Product and Geometric Mean Operators

For the product and geometric mean operators, the current transformed value is computed based on the (weighted) product of the cumulative, centered, or moving window values. If missing values are present in the moving window and the NOMISS operator is previously specified, the current transformed value is set to missing. Otherwise, the current transformed value is set to the product of the nonmissing values within the moving window. If a geometric mean operator is specified for a window of size n, the nth root of the product is taken. In cases where weights are specified explicitly, both the product and geometric mean operators normalize these exponents so that they sum to one.

Examples of Usage

The interest rates for a savings account are recorded for each month in the data set variable RATES. The cumulative interest rate for each month considering the entire account past history can be computed as follows:

convert rates=history / transformout=( + 1 cuprod - 1);

The interest rate for each quarter considering the previous quarter’s history can be computed as follows:

convert rates=lastqtr / transformout=( + 1 movprod 3 - 1);

The average interest rate for the previous quarter’s history can be computed as follows:

convert rates=lastqtr / transformout=( + 1 movprod (1 1 1) - 1);

Sequence Operators

For the sequence operators, the sequence values are used to compute the transformed values from the original values in a sequential fashion. You can add to or subtract from the original series or you can multiply or divide by the sequence values. The first sequence value is applied to the first observation of the series, the second sequence value is applied to the second observation of the series, and so on until the end of the sequence is reached. At this point, the first sequence value is applied to the next observation of the series and the second sequence value on the next observation and so on.

Let v 1 comma ellipsis comma v Subscript m Baseline be the sequence values and let x Subscript t, t equals 1 comma ellipsis upper N, be the original time series. The transformed series, y Subscript t, is computed as follows:

StartLayout 1st Row 1st Column y 1 2nd Column equals 3rd Column x 1 o p v 1 2nd Row 1st Column y 2 2nd Column equals 3rd Column x 2 o p v 2 3rd Row 1st Column Blank 2nd Column midline-horizontal-ellipsis 3rd Column Blank 4th Row 1st Column y Subscript m 2nd Column equals 3rd Column x Subscript m Baseline o p v Subscript m Baseline 5th Row 1st Column y Subscript m plus 1 2nd Column equals 3rd Column x Subscript m plus 1 Baseline o p v 1 6th Row 1st Column y Subscript m plus 2 2nd Column equals 3rd Column x Subscript m plus 2 Baseline o p v 2 7th Row 1st Column Blank 2nd Column midline-horizontal-ellipsis 3rd Column Blank 8th Row 1st Column y Subscript 2 m 2nd Column equals 3rd Column x Subscript 2 m Baseline o p v Subscript m Baseline 9th Row 1st Column y Subscript 2 m plus 1 2nd Column equals 3rd Column x Subscript 2 m plus 1 Baseline o p v Baseline 1 10th Row 1st Column y Subscript 2 m plus 2 2nd Column equals 3rd Column x Subscript 2 m plus 2 Baseline o p v Baseline 2 11th Row 1st Column Blank 2nd Column midline-horizontal-ellipsis 3rd Column Blank EndLayout

where o p equals plus comma minus comma asterisk comma normal o normal r slash.

Examples of Usage

The multiplicative seasonal indices are 0.9, 1.2. 0.8, and 1.1 for the four quarters. Let SEASADJ be a quarterly time series variable that has been seasonally adjusted in a multiplicative fashion. To restore the seasonality to SEASADJ, use the following transformation:

convert seasadj=seasonal /
        transformout=(seqmult (0.9 1.2 0.8 1.1));

The additive seasonal indices are 4.4, –1.1, –2.1, and –1.2 for the four quarters. Let SEASADJ be a quarterly time series variable that has been seasonally adjusted in additive fashion. To restore the seasonality to SEASADJ, use the following transformation:

convert seasadj=seasonal /
        transformout=(seqadd (4.4 -1.1 -2.1 -1.2));

Set Operators

For the set operators, the first parameter, n 1, represents the value to be replaced and the second parameter, n 2, represents the replacement value. The replacement can be localized to the beginning, middle, or end of the series.

Examples of Usage

Suppose that a store opened recently and that the sales history is stored in a database that does not recognize missing values. Even though demand may have existed prior to the stores opening, this database assigns the value of zero. Modeling the sales history may be problematic because the sales history is mostly zero. To compensate for this deficiency, the leading zero values should be set to missing with the remaining zero values unchanged (representing no demand).

convert sales=demand / transformout=(setleft (0 .));

Likewise, suppose a store is closed recently. The demand might still be present; hence, a recorded value of zero does not accurately reflect actual demand.

convert sales=demand / transformout=(setright (0 .));

Scale Operator

For the scale operator, the first parameter, n 1, represents the value associated with the minimum value (x Subscript normal m normal i normal n) and the second parameter, n 2, represents the value associated with the maximum value (x Subscript normal m normal a normal x) of the original series (x Subscript t). The scale operator rescales the original data to be between the parameters n 1 and n 2 as follows:

y Subscript t Baseline equals left-parenthesis left-parenthesis n 2 minus n 1 right-parenthesis slash left-parenthesis x Subscript normal m normal a normal x Baseline minus x Subscript normal m normal i normal n Baseline right-parenthesis right-parenthesis left-parenthesis x Subscript t Baseline minus x Subscript normal m normal i normal n Baseline right-parenthesis plus n 1
Examples of Usage

Suppose that two new product sales histories are stored in the variables X and Y and you want to determine their adoption rates. In order to compare their adoption histories, the variables must be scaled for comparison.

convert x=w / transformout=(scale 0 1);
convert y=z / transformout=(scale 0 1);

Adjust Operator

For the moving summation and product window operators, the window widths at the beginning and end of the series are smaller than those in the middle of the series. Likewise, if there are embedded missing values, the window width is smaller than specified. When preceded by the ADJUST operator, the moving summation (MOVSUM CMOVSUM) and moving product operators (MOVPROD CMOVPROD) are adjusted by the window width.

For example, suppose the variable X has 10 values, and the moving summation operator of width 3 is applied to X to create the variable Y with window width adjustment and the variable Z without adjustment.

convert x=y / transformout=(adjust movsum 3);
convert x=z / transformout=(movsum 3);

The preceding transformations result in the following relationship between Y and Z: y 1 equals 3 z 1, y 2 equals three-halves z 2, y Subscript t Baseline equals z Subscript t for t greater-than 2 because the first two window widths are smaller than 3.

For example, suppose the variable X has 10 values and the moving multiplicative operator of width 3 is applied to X to create the variable Y with window width adjustment and the variable Z without adjustment.

convert x=y / transformout=(adjust movprod 3);
convert x=z / transformout=(movprod 3);

The preceding transformations result in the following: y 1 equals z 1 cubed, y 2 equals z 2 Superscript 3 slash 2, y Subscript t Baseline equals z Subscript t for t greater-than 2 because the first two window widths are smaller than 3.

Moving T-Value Operators

The moving t-value operators (CUTVALUE, MOVTVALUE, CMOVTVALUE) compute the t-value of the cumulative series or moving window. They can be viewed as combinations of the moving average (CUAVE, MOVAVE, CMOVAVE) and the moving standard deviation (CUSTD, MOVSTD, CMOVSTD), respectively.

Percent Operators

The percentage operators compute the percent summation and the percent difference of the current value and the normal l normal a normal g left-parenthesis n right-parenthesis. The percent summation operator (PCTSUM) computes y Subscript t Baseline equals 100 x Subscript t Baseline slash normal c normal u normal s normal u normal m left-parenthesis x Subscript t minus n Baseline right-parenthesis. If any of the values of the preceding equation are missing or the cumulative summation is zero, the result is set to missing. The percent difference operator (PCTDIF) computes y Subscript t Baseline equals 100 left-parenthesis x Subscript t Baseline minus x Subscript t minus n Baseline right-parenthesis slash x Subscript t minus n. If any of the values of the preceding equation are missing or the lag value is zero, the result is set to missing.

For example, suppose the variable X contains the series. The percent summation of lag 4 is applied to X to create the variable Y. The percent difference of lag 4 is applied to X to create the variable Z.

convert x=y / transformout=(pctsum 4);
convert x=z / transformout=(pctdif 4);

Ratio Operators

The ratio operator computes the ratio of the current value and the normal l normal a normal g left-parenthesis n right-parenthesis value. The ratio operator (RATIO) computes y Subscript t Baseline equals x Subscript t Baseline slash x Subscript t minus n. If any of the values of the preceding equation are missing or the lag value is zero, the result is set to missing.

For example, suppose the variable X contains the series. The ratio of the current value and the lag 4 value of X is assigned to the variable Y. The percent ratio of the current value and lag 4 value of X is assigned to the variable Z.

convert x=y / transformout=(ratio 4);
convert x=z / transformout=(ratio 4 * 100);
Last updated: June 19, 2025