Proc means automatically uses nonmissing values in x1 to calculate mean of x1, or sum of x1, you don't need to use where statement.
proc means data=yourdata n mean sum;
var x1 x2;
run;
If you use the following 'where' statement, it is the same as above (SAS default!):
proc means;
var x1 x2;
where x1 ne . or x2 ne .;
run;
But If you use 'And' in where statement:
proc means;
var x1 x2;
where x1 ne . and x2 ne . ;
run;
The data you are using to do proc means will be limited to the only records having both x1 and x2 nonmissing values, say you are missing 5 records in x1 and 100 records in x2, 95 to 100 extra records for x1 will be deleted due to x2 is missing. The means of x1, x2 will be different than previous results.
In general, I am agree with windwater's method by using array in datastep. But if you only need to calculate mean or sum of x1, x2, you don't need to replace the missing values. Sometimes if you replaced a lot of missing values by 0, you pushed your data towards 0.
[此贴子已经被作者于2007-4-11 22:52:47编辑过]