S = 10;

N = 100;

P = 5000;

call randseed(12345);

Res = {0 , 0};

do rep = 1 to S;

X = j(N, P, .);

Y = j(N, 2, .);

call randgen(x, ’normal’);

call randgen(y, ’normal’);

Cor = corr(Y || X)[{1 2}, 3P+2)];

Res = Res + abs(Cor)[ ,<>];

end;

Res = Res / S;

print Res;

quit;

I know its the problem on Cor = corr(Y || X)[{1 2}, 3P+2)];

but can anyone tell me why its doesn't work fast and how to make changes in order to make it faster.

Thanks!!!!