Mean and sum of six variables: how to use only cases where at least four variables aren't missing
on 10-03-201310:30 PM - last edited on 10-10-201509:14 PM by LainieH
Sorry, I posted this topic in the wrong place, but I'm not able to delete it, or to move it in the discussion section ...
I try to construct a variable with SAS, but I have some difficulties.
I want to create a variable that is the mean (totmean) or the sum (totsum) of 6 variables (var1, var2,var3, var4, var5, var6). However, I want only participants who have responded to at least 4 items to be include. Those who have one or two missing for var1-var6 should be coded NA for totmean and totsum.
How I do that?
Sorry if the question sounds easy for some, but I'm new to SAS (I'm used to Stata). Optimally, I would like to be able to generate a variable (e.g. var_miss) that represent the number of cases with 0 missing, 1 missing, 2 missing, and so forth, and then use an if var_miss < 3 … For those who know Stata, I search an equivalence of the rowmiss option with the egen command. If it doesn’t exist, any other solution would be helpful!