Hello @Will_FBB See if this helps
data have;
input ID $ Month (x a b c) (:comma10.);
cards;
A 1 12,810 . . .
A 2 . 50 . .
A 3 . . 50 .
A 4 . . . 50
A 5 . . . .
A 6 . . . 2,020
A 7 . . . 2,000
A 8 . . . 29
A 9 . . . 300
A 10 . . . .
B 1 26,121 . . .
B 2 . 1,000 . .
B 3 . . . .
B 4 . . 600 2,035
B 5 . . . .
B 6 . 500 . .
B 7 . . . .
B 8 . . . 533
B 9 . . . 484
B 10 . . . .
;
data want;
do until(last.id);
set have;
by id;
array t(*) a--c;
array u(3) _temporary_ ;
retain _i _i1;
if _n_=1 then do;
_i=addrlong(t(1));
_i1=addrlong(u(1));
end;
if first.id then y=x;
else if n(of u(*))>0 then y+ (-sum(of u(*)));
output;
call missing(of u(*));
call pokelong(peekclong(_i,dim(t)*8),_i1,dim(t)*8);
end;
call missing(y,of u(*));
drop _:;
run;