d = sum(multiple_item ʃwhere conditionʅ);
The sum function returns the sum of an item that occurs multiple times. If a where condition is included, the function returns the sum of the occurrences for which the condition is true.
During data entry, the result of the sum calculation depends on where the statement is located. If the sum function is executed prior to the form or roster containing the item, it returns
default. If it is executed within the form or roster containing the item, it returns the sum up to the current occurrence number. If it is executed after the form or roster containing the item, it returns the sum for all occurrences of the item.
During batch editing, sum always returns the sum for all occurrences of the item.
If the value of an occurrence of the item is a special value (
default,
missing,
refused, or
notappl) the occurrence will not be included in the calculation. If none of the occurrences have values other than special values,
default is returned.
The function returns a decimal value of the sum.
TOTAL_INCOME = sum(INCOME);
TOTAL_FEMALE_INCOME = sum(INCOME where SEX = 2);