Apologies if this is a basic question, I haven't found what I'm looking for in help files.
I'm creating a variable based on the sums of other variables, depending on how I want this to treat missing values I understand that I have various options such as 'gen v3 = v1+v2' (which will return missing if either var is missing) or 'egen v3 = rsum(v1 v2) (to treat missing as 0). I know that I can use the missing option to return a missing value if all of the values in the varlist are missing.
However is there a simple solution if I wanted to return a missing if the number/proportion of missing values were over a defined threshold? e.g. if I want to sum 5 variables v1-v5 and treat missing data as 0, but return a missing value if more than 1 value or more than 2 values are missing rather than all 5 as 'egen v6 = rsum (v1 v2 v3 v4 v5), missing' will do?
I'm creating a variable based on the sums of other variables, depending on how I want this to treat missing values I understand that I have various options such as 'gen v3 = v1+v2' (which will return missing if either var is missing) or 'egen v3 = rsum(v1 v2) (to treat missing as 0). I know that I can use the missing option to return a missing value if all of the values in the varlist are missing.
However is there a simple solution if I wanted to return a missing if the number/proportion of missing values were over a defined threshold? e.g. if I want to sum 5 variables v1-v5 and treat missing data as 0, but return a missing value if more than 1 value or more than 2 values are missing rather than all 5 as 'egen v6 = rsum (v1 v2 v3 v4 v5), missing' will do?
Comment