Shift Values

Shift Values creates new variables that contain the values of existing variables from preceding or subsequent cases.

Name. Name for the new variable. This must be a name that does not already exist in the active dataset.

Get value from earlier case (lag). Get the value from a previous case in the active dataset. For example, with the default number of cases value of 1, each case for the new variable has the value of the original variable from the case that immediately precedes it.

Get value from following case (lead). Get the value from a subsequent case in the active dataset. For example, with the default number of cases value of 1, each case for the new variable has the value of the original variable from the next case.

Number of cases to shift. Get the value from the nth preceding or subsequent case, where n is the value specified. The value must be a non-negative integer.

  • If split file processing is on, the scope of the shift is limited to each split group. A shift value cannot be obtained from a case in a preceding or subsequent split group.
  • Filter status is ignored.
  • The value of the result variable is set to system-missing for the first or last n cases in the dataset or split group, where n is the value specified for Number of cases to shift. For example, using the Lag method with a value of 1 would set the result variable to system-missing for the first case in the dataset (or first case in each split group).
  • User-missing values are preserved.
  • Dictionary information from the original variable, including defined value labels and user-missing value assignments, is applied to the new variable. (Note: Custom variable attributes are not included.)
  • A variable label is automatically generated for the new variable that describes the shift operation that created the variable.

To Create a New Variable with Shifted Values

  1. From the menus, choose:

    Transform > Shift Values

  2. Select the variable to use as the source of values for the new variable.
  3. Enter a name for the new variable.
  4. Select the shift method (lag or lead) and the number of cases to shift.
  5. Click Change.
  6. Repeat for each new variable you want to create.