The matrix r is (2*t-1)*(2*t-1) but is it empty..may you help me?
Besides, I need to start the do from a negative number is this o.k.??
This is the program:
proc iml;
t=15;
a=2*t;
r=j(a-1,a-1,.);
do i= (1-t) to (t-1);
do j= (1-t) to (t-1);
az1= -(j-i);
az2= -(j-i);
bz1= -(j-i);
bz2= (j-i);
cz1= (j-i);
cz2= (j-i);
if j<0 then z1=az1;
z2=az2;
if j=0 then z1=bz1;
z2=bz2;
if j>0 then z1=cz1;
z2=cz2;
r[i,j]=probnorm(z2)-probnorm(z1);
end;
end;
print r;
quit;
Thanks in advance.
Waiting for your reply.
The program gives invalid subscript errors for the matrix r, since both i and j can be zero or negative. I suspect you need to change it to r[i+t, j+t] = ....
Thanks for your help.
I have just tried what you suggested. The matrix is now filled with numbers but they are not correct.
Why did you suggested putting (+t)?
If you declare a 29x29 matrix then you can only reference individual elements within it by using the integers 1 to 29 as row or column subscript indices. You were trying to use -14 to +14 as the indices, so my suggestion was to shift it back to the correct range by adding 15.
Since we don't know what numbers are correct, you need to tell us what you expect or give an example for t=3.
The correctness of the program depends on z2 and z1. You can check their correctness with the following:
1) Outside the loop, allocate
Lower=j(a-1,a-1,.);
Upper=j(a-1,a-1,.);
2) Within the loop, define
Lower[i+t,j+t] = z1;
Upper[i+t,j+t] = z2;
3) Print Lower and Upper after the loop.
BTW, since the normal CDF is effectively zero when z<-6 and is 1 when z>6, you can probably get by with a smaller value of t. In any case, switch from PROBNORM(z) to CDF("Normal",z), as suggested at the end of this article: Six reasons you should stop using the RANUNI function to generate random numbers - The DO Loop
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.