One of the advantages of programming in the SAS/IML language is its ability to transform data vectors with a single statement. For example, in data analysis, the log and square-root functions are often used to transform data so that the transformed data have approximate normality.

The following SAS/IML statements create a data vector, `x`, and apply several common transformations to the data:

proc iml; x = {1,2,4,5,10,100}; y = log(x); /** natural log **/ z = log10(x); /** log base 10 **/ u = sqrt(x); /** square root **/ |

Notice that you do not need to write a DO loop in order to compute a vector of quantities: the LOG, LOG10, and SQRT functions transform every element of the vector `x`.

There are many other useful data transformations. In fact, entire books have been written about ways to transform data. The following statements show a few other common transformations:

v = 1 + 2 * x - 3 * x##2; /** polynomial transform **/ s = (x - mean(x)) / sqrt(var(x)); /** standardize **/ q = y + z/2 - 5 * u; /** linear combination **/ |

In the preceding statements, the MEAN and VAR functions are used. These functions are available in SAS/IML 9.22. If you are using an earlier version of SAS/IML, you can use the subscript reduction operator (:) (for example, `(x-x[:])`) and call
the VAR module from my book.

The important point to remember is this: you do not need to write a loop in order to transform a data vector. Just write down the equation, and let the SAS/IML language do the rest.