Search code examples
sas-iml

How to vectorise in SAS/IML?


Suppose I have

  proc iml;
  x = {1,2,3};

I am interested in computing CDF ('F',1,2, ....) for every element of x. Of course, I can write a loop, but I would like to know the smart way of doing it, i.e. vectorise?

I tried to google but could not find anything, any takers?


Solution

  • When SAS/IML calls Base SAS functions, you can usually pass in a vector in place of the scalar arguments. In your example, it's as easy as c = cdf("Normal", x);

    For more information, you can read about how to call Base SAS functions from SAS/IML. If the need arises, you can also pass in vectors for MULTIPLE arguments, provided that the vectors are the same size.