The DO Loop
Statistical programming in SAS with an emphasis on SAS/IML programs![Bin observations by using custom cut points and unevenly spaced bins](https://blogs.sas.com/content/iml/files/2013/07/binobs.png)
It is often useful to partition observations for a continuous variable into a small number of intervals, called bins. This familiar process occurs every time that you create a histogram, such as the one on the left. In SAS you can create this histogram by calling the UNIVARIATE procedure. Optionally,
![Six reasons you should stop using the RANUNI function to generate random numbers](https://blogs.sas.com/content/iml/files/2011/08/generaterandom.png)
Are you still using the old RANUNI, RANNOR, RANBIN, and other "RANXXX" functions to generate random numbers in SAS? If so, here are six reasons why you should switch from these older (1970s) algorithms to the newer (late 1990s) Mersenne-Twister algorithm, which is implemented in the RAND function. The newer
![How does the IF-THEN statement in SAS treat a missing value?](https://blogs.sas.com/content/iml/files/2013/06/t_ifthenmiss.png)
Every programming language has an IF-THEN statement that branches according to whether a Boolean expression is true or false. In SAS, the IF-THEN (or IF-THEN/ELSE) statement evaluates an expression and braches according to whether the expression is nonzero (true) or zero (false). The basic syntax is if numeric-expression then do-computation;
![Obtain data sets from the book Statistical Programming with SAS/IML Software](https://blogs.sas.com/content/iml/files/2017/01/AdvancedAnalytics-2.png)
On the Web site for the book Statistical Programming with SAS/IML Software, I provide instructions on how to download the sample data sets and install them so that they can be used from within SAS/IML Studio. When I wrote the book I did not anticipate that SAS users might want
![Count the number of unique rows in a matrix](https://blogs.sas.com/content/iml/files/2013/06/countuniqrows.png)
How do you count the number of unique rows in a matrix? The simplest algorithm is to sort the data and then iterate down the rows, comparing each row with the previous row. However, this algorithm has two shortcomings: it physically sorts the data (which means that the original locations
![Using simulation to compute a power curve](https://blogs.sas.com/content/iml/files/2013/05/simttest.png)
Last week I showed how to use simulation to estimate the power of a statistical test. I used the two-sample t test to illustrate the technique. In my example, the difference between the means of two groups was 1.2, and the simulation estimated a probability of 0.72 that the t