Skip to main content
Mail a PDF copy of this page to:
(Your email address will not be added to a mailing list)
Show menu Show menu

Stack columns


Performs a multivariate to univariate conversion by stacking several spreadsheet columns into a new column.

The procedure creates 3 new columns for data, variables and cases.


When the original data are:

Stack columns example

After "Stacking", the resulting spreadsheet shows variables Hour12 and Hour24 stacked with variable Patient as variable with case identification:

Stack columns example

The Stack columns procedure may be useful when you have to rearrange your data for procedures such as Serial measurements analysis, or Bland-Altman plot with multiple measurements per subject.

Required input

Stack columns dialog box

  • Source: Variables to stack
    • Variables: select the variables of interest in the top left box and next click the right arrow button to move the selection to the Selected variables list.
    • Variable with case identification: a variable that will be replicated in one column for each stacked variable. If left blank, the row number will be used for case identification.
  • Target: Spreadsheet columns for new data and identifier variables.
    • Option List empty columns only: if this option is selected, only those columns that are empty will be listed in the following selection boxes.
    • Stacked case identification column: a new spreadsheet column that will be filled with a case identification, replicated for each stacked variable. (column Case in the example above)
    • Source variables identifier column: a spreadsheet column that will be filled with the variables names (column Hour in the example above)
    • Stacked data column: a spreadsheet column that will be filled with the stacked data (column Data in the example above)
    • Option Extract numbers from variable names: if the variable names contain numbers, like in the example Hour12 and Hour24, the numbers 12 and 24 will be extracted from the variables names and placed in the Source variables identifier column (see example below)
    • Option Clear columns: the selected columns will be cleared prior to storing the stacked data.

Click OK to proceed.

More examples

Example with the option "Extract numbers from variable names" selected:

Stack columns example

The numbers 12 and 24 are extracted from the variables names, making the variable Hour suitable for numerical analysis or inclusion in numerical procedures.

Example with the selection "Variable with case identification" left blank:

Stack columns example

The row number is used as case identifier.

See also