I have a dataset with about 50 variables. I want to do a dynamic counting of non missing values for these variables, meaning that I start with the variable with the most non missing observations (var1), then I want to add a second variable (var2) and count the number of non missing observations for both var1 and var2, whereby the number of non missing is the highest possible among the existing variables. For example, if I have just five variables: var1 non missing 1000 var2 non missing 800 var3 non missing 400 var4 non missing 850 var5 non missing 330 I would start with var1, and then count the number of observations with non missing of two variables. var1+var2 non missing 720 var1+var3 non missing 780 var1+var4 non missing 620 var1+var5 non missing 150 Then var1+var3 give me the most observations, so I would keep them and continue with the most number of observations with non missing for three variables. var1+var3+var2 var1+var3+var4 var1+var3+var5 etc. until I have the result for all the variables (5 in this example). A possible result being var1+var3+var2+var5+var4
... View more