What I don't immediately see is how to best identify the added or removed element, but one could improve efficiency a lot. RC marks the spot: data have;
infile cards dlm=',';
input h1-h9;
cards;
1,2,4,8,16,32,64,128,256
;
run;
data want2;
set have;
array h{*} h1-h9;
array x{*} x1-x9;
k=-1;
sum=0;
rc=graycode(k,of x{*});
output;
do i=1 to 2**dim(x)-1;
rc=graycode(k,of x{*});
if x{rc} then
sum=sum+h{rc};
else
sum=sum-h{rc};
output;
end;
keep h1-h9 sum k;
run;
... View more