The DO Loop
Statistical programming in SAS with an emphasis on SAS/IML programs![Generate all permutations in SAS](https://blogs.sas.com/content/iml/files/2011/08/t_allpermutations.png)
In a previous post, I discussed how to generate random permutations of N elements. But what if you want to systematically iterate through a list of ALL permutations of N elements? In the SAS DATA step you can use the ALLPERM subroutine in the SAS DATA step. For example, the
![A statistical word puzzle!](https://blogs.sas.com/content/iml/files/2011/08/wordpuzzle.png)
Today's post is a puzzle. Why? Well, my wife loves solving word puzzles, and today is our wedding anniversary. Last year, I bought her a Jumble® book. This year, I've created a one-of-a-kind scrambled word puzzle just for her. (But you can play, too!) I created this puzzle by using
![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