0
votes

I have ten variables, some with missing data. I know that using mean(of x1-x10) will compute the mean to include missing data.

How do I tell SAS to compute the mean for complete data (x1-x10)/10 and for data with exactly one missing value (x1-x10)/9? But to return a missing value as the mean for data with more than one missing value?

I've been trying to use if/then statements, but I'm not quite sure where I'm going wrong..

1
missing values are NOT included in the mean computation.Richard
Okay, thanks. But the mean function will output a mean even if there is missing data?user12310746
You should answer this question by trying it. You have some data so give it a shot.Reeza
The mean function returns the average of the non-missing values. If all the values are missing the returned value is missing.Richard

1 Answers

1
votes

The NMISS() function can count the number of missing values.

if nmiss(of x1-x10) <= 1 then want=mean(of x1-x10);
else want=.;