I'm trying to calculate an average of nine different numerical variables as a new variable in Stata (version 14). Some of these nine variables have missing values. I would like Stata to divide the sum of the variables by the number of valid variables for that specific case. For example, patient 1 has a sum of 40 with 4 valid variables while patient 2 has a sum of 42 with 5 valid variables. Which function/command do I need to use for this?

Thank you in advance.

More Cédric Dikovec's questions See All
Similar questions and discussions