If "eksi" can't be greater than 1, you should constrain it. The expression (1-eksi**2)**(n/2) is undefined when eksi > 1 and n is odd. My comment is that you should be very concerned about convergence. Computing an infinite summation by summing the first 20 terms is only going to work if the series converges very quickly. There are many examples in numerical analysis that show why truncating an infinite series can lead to large errors. Along the same lines, using terms that involve tha GAMMA and FACT functions often lead to numerical errors, which is why I prefer the PDF calls.. Another comment is that you are not taking advantage of the vector nature of SAS/IML. Perhaps you can compute with w2, rather than have a DO loop over the index. Lastly, you can save some computational time if you list some of the statements out of the innermost loops. For example, the expression for 'negb' depends only on 'i', so you do not need to compute it at every iteration of k1 and k2.
... View more