I've re-coded your IF sequence a bit. It still does exactly the same - I just find it easier to debug.
data rawcompustat8 missed_cases;
set work.rawcompustat6;
if pstkrv>0 then bm=(seq-pstkrv+txditc);
else if pstkrv<0 then
do;
if pstkl>0 then bm=(seq-pstkl+txditc);
else if pstkl<0 then
do;
if pstk>0 then bm=(seq-pstk+txditc);
else if pstk<0 then bm=(seq+txditc);
else output missed_cases;
end;
end;
output rawcompustat8;
run;
I can see 2 reasons for ending up with missings.
1. You don't cover cases where your "selection" variables are exactly zero - so there "BM" will be missing
2. For the case where "IF PSTKRV<0 and PSTKL<0 and PSTK<0" is true one or both of the 2 variables you're summing is missing - so the result stored in BM would be missing (which is represented as a '.').
I've added a table for missed cases. In there will be all rows you've missed which should allow you to determine why your code is not working as expected.