The DO Loop
Statistical programming in SAS with an emphasis on SAS/IML programs![Find variables common to multiple data sets](https://blogs.sas.com/content/iml/files/2013/02/t_varcommon1.png)
Last week the SAS Training Post blog posted a short article on an easy way to find variables in common to two data sets. The article used PROC CONTENTS (with the SHORT option) to print out the names of variables in SAS data sets so that you can visually determine
![Simulate discrete variables by using the "Table" distribution](https://blogs.sas.com/content/iml/files/2017/02/AdvancedAnalytics-4.png)
I wanted to write a blog post about the "Table distribution" in SAS. The Table distribution, which is supported by the RAND and the RANDGEN function, enables you to specify the probability of selecting each of k items. Therefore you can use the Table distribution to sample, with replacement, from
![Oh, those pesky temporary variables!](https://blogs.sas.com/content/iml/files/2013/01/t_tempmatrix.png)
The SAS/IML language secretly creates temporary variables. Most of the time programmers aren't even aware that the language does this. However, there is one situation where if you don't think carefully about temporary variables, your program will silently produce an error. And as every programmer knows, silent wrong numbers are
![Breaking bad programming habits. What's yours?](https://blogs.sas.com/content/iml/files/2013/01/t_noreshape.png)
I like to be efficient in my SAS/IML programs, but sometimes I get into bad habits. Recently I realized that I was reshaping a bunch of SAS/IML row vectors because I wanted to write them to a SAS data set. This is completely unnecessary! The SAS/IML language will create a
![Reading big data in the SAS/IML language](https://blogs.sas.com/content/iml/files/2013/01/ReadBlocks.png)
A SAS/IML user on a discussion forum was trying to read data into a SAS/IML matrix, but the data was so large that it would not fit into memory. (Recall that SAS/IML matrices are kept in RAM.) After a few questions, it turned out that the user was trying to
![Generate binary outcomes with varying probability](https://blogs.sas.com/content/iml/files/2012/11/t_callrand.png)
A while ago I saw a blog post on how to simulate Bernoulli outcomes when the probability of generating a 1 (success) varies from observation to observation. I've done this often in SAS, both in the DATA step and in the SAS/IML language. For example, when simulating data that satisfied