Next: FLIP, Previous: COMPUTE, Up: Data Manipulation [Contents][Index]

COUNTvar_name=var… (value…). Eachvaluetakes one of the following forms:numberstringnum1THRUnum2MISSING SYSMIS wherenum1is a numeric expression or the words`LO`

or`LOWEST`

andnum2is a numeric expression or`HI`

or`HIGHEST`

.

`COUNT`

creates or replaces a numeric *target* variable that
counts the occurrence of a *criterion* value or set of values over
one or more *test* variables for each case.

The target variable values are always nonnegative integers. They are never missing. The target variable is assigned an F8.2 output format. See Input and Output Formats. Any variables, including string variables, may be test variables.

User-missing values of test variables are treated just like any other
values. They are **not** treated as system-missing values.
User-missing values that are criterion values or inside ranges of
criterion values are counted as any other values. However (for numeric
variables), keyword `MISSING`

may be used to refer to all system-
and user-missing values.

`COUNT`

target variables are assigned values in the order
specified. In the command `COUNT `

, the
following actions occur:
`A`=`A` `B`(1) /`B`=`A` `B`(2).

- - The number of occurrences of 1 between
`A`and`B`is counted. - -
`A`is assigned this value. - - The number of occurrences of 1 between
`B`and the**new**value of`A`is counted. - -
`B`is assigned this value.

Despite this ordering, all `COUNT`

criterion variables must exist
before the procedure is executed—they may not be created as target
variables earlier in the command! Break such a command into two
separate commands.

The examples below may help to clarify.

- Assuming
`Q0`

,`Q2`

, …,`Q9`

are numeric variables, the following commands:- Count the number of times the value 1 occurs through these variables
for each case and assigns the count to variable
`QCOUNT`

. - Print out the total number of times the value 1 occurs throughout
*all*cases using`DESCRIPTIVES`

. See DESCRIPTIVES, for details.

COUNT QCOUNT=Q0 TO Q9(1). DESCRIPTIVES QCOUNT /STATISTICS=SUM.

- Count the number of times the value 1 occurs through these variables
for each case and assigns the count to variable
- Given these same variables, the following commands:
- Count the number of valid values of these variables for each case and
assigns the count to variable
`QVALID`

. - Multiplies each value of
`QVALID`

by 10 to obtain a percentage of valid values, using`COMPUTE`

. See COMPUTE, for details. - Print out the percentage of valid values across all cases, using
`DESCRIPTIVES`

. See DESCRIPTIVES, for details.

COUNT QVALID=Q0 TO Q9 (LO THRU HI). COMPUTE QVALID=QVALID*10. DESCRIPTIVES QVALID /STATISTICS=MEAN.

- Count the number of valid values of these variables for each case and
assigns the count to variable

Next: FLIP, Previous: COMPUTE, Up: Data Manipulation [Contents][Index]