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


12.4 COUNT

COUNT var_name = var… (value…).

Each value takes one of the following forms:
        number
        string
        num1 THRU num2
        MISSING
        SYSMIS
where num1 is a numeric expression or the words LO  or LOWEST
      and num2 is 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 A=A B(1) /B=A B(2)., the following actions occur:

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.

  1. Assuming Q0, Q2, …, Q9 are numeric variables, the following commands:
    1. Count the number of times the value 1 occurs through these variables for each case and assigns the count to variable QCOUNT.
    2. 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.
    
  2. Given these same variables, the following commands:
    1. Count the number of valid values of these variables for each case and assigns the count to variable QVALID.
    2. Multiplies each value of QVALID by 10 to obtain a percentage of valid values, using COMPUTE. See COMPUTE, for details.
    3. 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.
    

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