Hello!
I am trying to write a SAS (macro) function that returns a value, in an effort to create a PROBBNRM function analog that allows customized lower/upper bounds and accepts non-standardized bivariate normal distribution means/variances.
I have written a macro function (I think) that computes the desired probability from user input,
%JointProbability(mu1, mu2, sigma1, sigma2, corr, critx1, critx2, crity1, crity2);quit;
The code for the macro is below, but all it does is assign the resulting probability to a global variable MyOutput, rather than return a value. I intend to use this function in proc nlp to fit a bivariate model (Platform: Windows 2K, SAS 9 used).
Would anyone have any suggestions on how to proceed?
Thank you!!
Serge
%macro JointProbability(xMean,yMean,xSD,ySD,rho,xLower,xUpper,yLower,yUpper);
data;
m1=&xMean;m2=&yMean;
s1=&xSD;s2=&ySD;
r=ρ
cx1=&xLower;cx2=&xUpper;
cy1=&yLower;cy2=&yUpper;
zx1=(cx1-m1)/s1;zx2=(cx2-m1)/s1;zx3=(cx1-m1)/s1;zx4=(cx2-m1)/s1;
zy1=(cy1-m2)/s2;zy2=(cy2-m2)/s2;zy3=(cy2-m2)/s2;zy4=(cy1-m2)/s2;
p_out=probbnrm(zx2,zy2,r)-probbnrm(zx3,zy3,r)-probbnrm(zx4,zy4,r)+probbnrm(zx1,zy1,r);
%global MyOutput;
call symput('MyOutput',p_out);
run;
%mend;
I am trying to write a SAS (macro) function that returns a value, in an effort to create a PROBBNRM function analog that allows customized lower/upper bounds and accepts non-standardized bivariate normal distribution means/variances.
I have written a macro function (I think) that computes the desired probability from user input,
%JointProbability(mu1, mu2, sigma1, sigma2, corr, critx1, critx2, crity1, crity2);quit;
The code for the macro is below, but all it does is assign the resulting probability to a global variable MyOutput, rather than return a value. I intend to use this function in proc nlp to fit a bivariate model (Platform: Windows 2K, SAS 9 used).
Would anyone have any suggestions on how to proceed?
Thank you!!
Serge
%macro JointProbability(xMean,yMean,xSD,ySD,rho,xLower,xUpper,yLower,yUpper);
data;
m1=&xMean;m2=&yMean;
s1=&xSD;s2=&ySD;
r=ρ
cx1=&xLower;cx2=&xUpper;
cy1=&yLower;cy2=&yUpper;
zx1=(cx1-m1)/s1;zx2=(cx2-m1)/s1;zx3=(cx1-m1)/s1;zx4=(cx2-m1)/s1;
zy1=(cy1-m2)/s2;zy2=(cy2-m2)/s2;zy3=(cy2-m2)/s2;zy4=(cy1-m2)/s2;
p_out=probbnrm(zx2,zy2,r)-probbnrm(zx3,zy3,r)-probbnrm(zx4,zy4,r)+probbnrm(zx1,zy1,r);
%global MyOutput;
call symput('MyOutput',p_out);
run;
%mend;