I just don't see the point of writing your own data step code to do summation, when SAS already has a PROC that does this, and handles missings and does error checking, all at no extra charge.
proc summary nway data=have;
class cx y;
var z;
output out=want sum=sum_z;
run;
... View more