You can add a sum statement to accumulate the total. Is this what you are trying to do:
data new; set orig_data;
IF ICD = 10 then do;
IF "A00" <= substr(death_cause,1,3) <= "A99" then do;
IF substr(death_cause,1,3) in ("A20","A21","A25") then do; deathcause_2=2; end;
Else deathcause_1=1; End;
end;
IF ICD = 9 then do;
IF "001" <= substr(death_cause,1,3) <= "139" then do;
IF substr(death_cause,1,3) in ("032","033","034") then do; deathcause_2=2; end;
Else deathcause_1=1; End;
end;
total_deathcause_2+deathcause_2;
total_deathcause_1+deathcause_1;
run;
... View more