The DO Loop
Statistical programming in SAS with an emphasis on SAS/IML programs![Reordering data to match a target order](https://blogs.sas.com/content/iml/files/2012/07/t_targetrank.png)
Suppose that you have two data vectors, x and y, with the same number of elements. How can you rearrange the values of y so that they have the same relative order as the values of x? In other words, find a permutation, π, of the elements of y so
![Compute the multivariate normal density in SAS](https://blogs.sas.com/content/iml/files/2012/07/mvnormalpdf.png)
I've been working on a new book about Simulating Data with SAS. In researching the chapter on simulation of multivariate data, I've noticed that the probability density function (PDF) of multivariate distributions is often specified in a matrix form. Consequently, the multivariate density can usually be computed by using the
![Create an ID vector for repeated measurements](https://blogs.sas.com/content/iml/files/2012/06/t_id1.png)
I often use the SAS/IML language for simulating data with certain known properties. In fact, I'm writing a book called Simulating Data with SAS. When I simulate repeated measurements (sometimes called replicated data), I often want to generate an ID variable that identifies which measurement is associated with which subject
![Compute a running total for a "window" of time](https://blogs.sas.com/content/iml/files/2012/06/t_runningtotal.png)
A reader wrote for help with a computational problem. He has a vector of length N and the vector contains integer values in the range [1, 120], which represent months for which events occurred over a 10-year period. The question is: what is the 24-month period for which the most
![Eight tips to make your simulation run faster](https://blogs.sas.com/content/iml/files/2017/01/AdvancedAnalytics-2.png)
"Help! My simulation is taking too long to run! How can I make it go faster?" I frequently talk with statistical programmers who claim that their "simulations are too slow" (by which they mean, "they take too long"). They suspect that their program is inefficient, but they aren't sure why.
![Did you know that PROC IML automatically loads certain modules?](https://blogs.sas.com/content/iml/files/2017/01/AdvancedAnalytics-1.png)
In the SAS/IML language, a user-defined function or subroutine is called a module. Modules are used to extend the capability of the SAS/IML language. Usually you need to explicitly load modules before you use them, but there are two cases where PROC IML loads a module automatically. Modules in IMLMLIB