OK. That would be more simple. Check if data is similar with yours.
data have;
input id $ a b c d;
cards;
aa . . . .
a1 1 . . .
b2 2 1 . .
c3 3 2 1 .
;
proc iml;
use have ;
read all var _num_ into x[c=vname r=id];
close;
x=choose(x=.,0,x);
want=x+t(x);
create want from want[c=vname r=id];
append from want[r=id];
close;
quit;
... View more