/* divz Daniel Brockman 20110706 Avoid div by zero or missing value. Ex: 0 = number / 0 . */ /* for use in data steps */ %macro divz(result,num,den) ; options nosymbolgen nomprint nomlogic ; ; if (missing(&den) or missing(&num)) then &result = 0 ; /* if either operand missing */ else if (&den = 0) then &result = 0 ; /* if denominator is zero */ /* if denominator relatively very smaller than numerator */ else if (abs(&den) < abs(&num*1e-12)) then &result = 0 ; else &result = &num / &den ; /* normal division */ ; options symbolgen mprint mlogic ; %mend divz ;