I am trying to create a SAS macro that I can call for calculating ratio of variables. Here is how I have defined the ratio and used in a SAS dataset. I am getting error. What I am doing wrong? Thanks.
%macro ratio(num, den, ratio);
%if &den = . %then &ratio = -999999;
%else %if &den = 0 %then &ratio = -999998;
%else %if &num = . %then &ratio = -999997;
%else &ratio = &num/&den;
%mend ratio;
data model_data;
set mysas.model_data;
call %ratio(var1,var2,ratio_var1_to_var2);
run;