Overview (VARSTOCASES command)

A variable contains information that you want to analyze, such as a measurement or a test score. A case is an observation, such as an individual or an institution. In a simple data structure, each variable is a single column in your data. So if you are measuring test scores, for example, all test score values would appear in only one column. In a simple data structure, each case is a single row in your data. So if you were measuring scores for all students in a class, there would be a row for each student.

VARSTOCASES restructures complex data structures (in which information about a variable is stored in more than one column) into a data file in which those measurements are organized into separate rows of a single column. It replaces the active dataset.

You can use VARSTOCASES to restructure data files in which repeated measurements of a single case were recorded in one row into a new data file in which each measurement for a case appears in a new row.

Options

Creating New Variables. You can create an identification variable that identifies the row in the original data file that was used to create a group of new rows, a count variable that contains the number of new rows generated by a row in the original data, and one or more index variables that identify the original variable from which the new row was created.

Variable Selection. You can use the DROP and KEEP subcommands to specify which variables from the original data file are included in the new data file.

Basic Specification

The basic specification is one or more MAKE subcommands, each of which specifies a list of variables to be combined into a single variable in which each value is displayed on a separate row.

Subcommand Order

Subcommands can be specified in any order.

Syntax Rules

  • The MAKE subcommand is required and can be specified as many times as needed.
  • The rest of the subcommands can be specified only once.

Operations

  • Row order. New rows are created in the order in which the variables are specified on the FROM list.
  • Propagated variables. Variables that are not named on the MAKE or DROP subcommands are kept in the new data file. Their values are propagated for each new row.
  • Split file processing. The SPLIT FILE command does not affect the results of VARSTOCASES. If split file processing is in effect, it will remain in effect in the new data file unless a variable that is used to split the file is named on the MAKE or DROP subcommands.
  • Weighted files. The WEIGHT command does not affect the results of VARSTOCASES. If original data are weighted, the new data will be weighted unless the variable that is used to split the file is named on the MAKE or DROP subcommands.
  • Selected cases. The FILTER and USE commands do not affect the results of VARSTOCASES. It processes all cases.

Limitations

The TEMPORARY command cannot be in effect when VARSTOCASES is executed.