Examples (COUNT command)
Counting Occurrences of a Single Value
COUNT TARGET=V1 V2 V3 (2).
- The value of TARGET for each case will be either 0, 1, 2, or 3, depending on the number of times the value 2 occurs across the three variables for each case.
- TARGET is a numeric variable
with an
F8.2
format.
Counting Occurrences of a Range of Values and System-Missing Values
COUNT QLOW=Q1 TO Q10 (LO THRU 0)
/QSYSMIS=Q1 TO Q10 (SYSMIS).
- Assuming that there are 10 variables between and including Q1 and Q10 in the active dataset, QLOW ranges from 0 to 10, depending on the number of times a case has a negative or 0 value across the variables Q1 to Q10.
- QSYSMIS ranges from 0 to 10, depending on how many system-missing values are encountered for Q1 to Q10 for each case. User-missing values are not counted.
- Both QLOW and QSYSMIS are numeric variables and have
F8.2
formats.
Counting Occurrences of String Values
COUNT SVAR=V1 V2 ('male ') V3 V4 V5 ('female').
- SVAR ranges from 0 to 5, depending on the number of times a case has a value of male for V1 and V2 and a value of female for V3, V4, and V5.
- SVAR is a numeric variable
with an
F8.2
format.