The DO Loop
Statistical programming in SAS with an emphasis on SAS/IML programs![How can you reshape a matrix?](https://blogs.sas.com/content/iml/files/2011/08/t_reshape.png)
Sometimes it is convenient to reshape the data in a matrix. Suppose you have a 1 x 12 matrix. This same data can fit into several matrices with different dimensions: a 2 x 6 matrix, a 3 x 4 matrix, a 4 x 3 matrix, and so on. The SHAPE function enables you to specify the number of
![Scrambling (and unscrambling) words](https://blogs.sas.com/content/iml/files/2011/08/t_permutation.png)
My previous post on creating a random permutation started me thinking about word games. My wife loves to solve the daily Jumble® puzzle that runs in our local paper. The puzzle displays a string of letters like MLYBOS, and you attempt to unscramble the letters to make an ordinary word.
![Generating random permutations](https://blogs.sas.com/content/iml/files/2011/08/t_randomperm.png)
I recently read a paper that described a SAS macro to carry out a permutation test. The permutations were generated by PROC IML. (In fact, an internet search for the terms "SAS/IML" and "permutation test" gives dozens of papers in recent years.) The PROC IML code was not as efficient
![Matrices, eigenvalues, Fibonacci, and the golden ratio](https://blogs.sas.com/content/iml/files/2011/08/t_goldenratio.png)
A previous post described a simple algorithm for generating Fibonacci numbers. It was noted that the ratio between adjacent terms in the Fibonacci sequence approaches the "Golden Ratio," 1.61803399.... This post explains why. In a discussion with my fellow blogger, David Smith, I made the comment "any two numbers (at
![Reading SAS data sets](https://blogs.sas.com/content/iml/files/2017/02/AdvancedAnalytics-4.png)
Often, the first step of a SAS/IML program is to use the USE, READ, and CLOSE statements to read data from a SAS data set into a vector or matrix. There are several ways to read data: Read variables into vectors of the same name. Read one or more variables
![Using data to define hurricane season](https://blogs.sas.com/content/iml/files/2011/08/t_hurricaneseason.png)
In a previous blog post about hurricanes, I created a histogram of the occurrence of tropical cyclones in the Atlantic basin during the years 1988–2003. That histogram shows that the peak of hurricane activity occurs in the second week of September, but also that a majority of tropical storms occur