Example: We have 3 variables, ‘I like to hang around with my friends during my spare time’ (friends), ‘I like to drink alcohol during my spare time’ (alcohol) and ‘I like to smoke cigarettes during my spare time’ (smoke).

Let’s assume, that the variable ‘friends’ has a missing value, the variable ‘alcohol’ has a value of 1 and ‘smoke’ has a value of 2.

COMPUTE rockrollplus = (friends + alcohol + smoke)/3.

Only counts the sum if the respondent has answered every question. In this case the value will be 0, because the value for ‘friends’ is missing.

COMPUTE rockrollsum = sum(friends,alcohol,smoke)/3.

Counts the sum even with missing values. In this case the mean will be 1, because 1+2 / 3 = 1.

COMPUTE rockrollmean = mean(friends,alcohol,smoke).

Counts the mean even with missing values, but divides the sum with the number of variables with non-missing values. In this case the mean would be 1,5, because 1+2 / 2 = 1,5.

The formula using the mean function is usually the best, except with a lot of missing values. For example, if we only had one non-missing value such as ‘smoke = 2’, the mean would be 2, even when two variables have missing values. A solution would be a formula like this:

COMPUTE rockrollmean2 = mean.2(friends,alcohol,smoke).

This formula counts the mean only when at least two of the variables have non-missing values.