Hello @alepage,
@alepage wrote:
(...)
if not missing(writtenUnit_HyFi_sas) and not missing(writtenUnit_harmony) then
do;
if writtenUnit_HyFi_sas eq 0 then wp_diff_pct = 0.0000;
else wp_diff_pct = round((writtenPremium_harmony / writtenPremium_HyFi_sas) - 1,0.00001);
end;
run;
It is good practice to check for missing values and zero denominators before dividing two numbers. Your code above has all the necessary IF-THEN/ELSE statements for those checks, but then surprisingly divides the values of two variables which were not checked in the IF conditions.
The code would look much more consistent -- and, most importantly, avoid the "division by zero" problem -- with
either writtenUnit_harmony / writtenUnit_HyFi_sas in the division
or writtenPremium_harmony and writtenPremium_HyFi_sas, respectively, in the IF conditions.
... View more