Overview (COUNT command)

COUNT creates a numeric variable that, for each case, counts the occurrences of the same value (or list of values) across a list of variables. The new variable is called the target variable. The variables and values that are counted are the criterion variables and values. Criterion variables can be either numeric or string.

Basic Specification

The basic specification is the target variable, an equals sign, the criterion variable, and the criterion values enclosed in parentheses.

Syntax Rules

  • Use a slash to separate the specifications for each target variable.
  • The criterion variables specified for a single target variable must be either all numeric or all string.
  • Each value on a list of criterion values must be separated by a comma or space. String values must be enclosed in quotes.
  • The keywords THRU, LOWEST (LO), HIGHEST (HI), SYSMIS, and MISSING can be used only with numeric criterion variables.
  • A variable can be specified on more than one criterion variable list.
  • You can use the keyword TO to specify consecutive criterion variables that have the same criterion value or values.
  • You can specify multiple variable lists for a single target variable to count different values for different variables.

Operations

  • Target variables are always numeric and are initialized to 0 for each case. They are assigned a dictionary format of F8.2.
  • If the target variable already exists, its previous values are replaced.
  • COUNT ignores the missing-value status of user-missing values. It counts a value even if that value has been previously declared as missing.
  • The target variable is never system-missing. To define user-missing values for target variables, use the RECODE or MISSING VALUES command.
  • SYSMIS counts system-missing values for numeric variables.
  • MISSING counts both user- and system-missing values for numeric variables.