There are two errors here:
1) The default "range" for the REPLACE stmt is CURRENT, so the second call to REPLACE (outside the loop) isn't doing what you want.
2) The REPLACE stmt replaces variables that are in common to the data set and the IML program. Inside the loop, you are trying to update the A1, A2, and A3 variables, but you haven''t changed those vectors. You are updating the NN matrix, but this matrix is not "linked" or connected to the A1-A3 variables, even though it was created from them.
I find that it is easiest and fastest to use REPLACE ALL rather than REPLACE CURRENT or REPLACE POINT. I recommend that you update the NN matrix, then copy the columns of NN back into A1-A3, then use REPLACE ALL, as follows:
do i=1 to 2;
do j=1 to 3;
if i^=j then nn[i,j]=nn[i,j]*1/(1-wr/2);
end;
end;
A1 = nn[,1]; A2 = nn[,2]; A3 = nn[,3];
replace all var{A1 A2 A3};