Hello,
I have what feels like a very elementary problem, yet so far I have failed to find a proper solution to it. For various family members, a closed question on ancestry was asked and I simply would like to construct a variable that counts the number of distinct values across those variables for each respondent, disregarding missings. For example, if the variable is missing for 2 family members and has the value 4 in the other cases, the new variable should be 1, if the row of values is 3 3 4 3 5 . . , it should be 3 etc.
Does anyone know an easy way to do this? Thanks!
Best,
Viktor
I have what feels like a very elementary problem, yet so far I have failed to find a proper solution to it. For various family members, a closed question on ancestry was asked and I simply would like to construct a variable that counts the number of distinct values across those variables for each respondent, disregarding missings. For example, if the variable is missing for 2 family members and has the value 4 in the other cases, the new variable should be 1, if the row of values is 3 3 4 3 5 . . , it should be 3 etc.
Does anyone know an easy way to do this? Thanks!
Best,
Viktor
Comment