The DO Loop
Statistical programming in SAS with an emphasis on SAS/IML programs![Find the label of a variable in SAS](https://blogs.sas.com/content/iml/files/2024/05/vlabel1.png)
Sometimes labels for variables get "dropped" during data preparation and cleaning. One example is when data are transposed from "wide form" to "long form." For example, suppose a data set has three variables, X, Y, and Z, each with labels. If you transpose the data to long form, the new
![Create filled density plots in SAS](https://blogs.sas.com/content/iml/files/2024/05/fillDensity2-480x336.png)
A SAS programmer wanted to visualize density estimate for some univariate data. The data had several groups, so he wanted to create a panel of density estimate, which you can easily do by using PROC SGPANEL in SAS. However, the programmer's boss wanted to see filled density estimates, such as
![On the correctness of a discrete simulation](https://blogs.sas.com/content/iml/files/2024/05/diceSim3-640x336.png)
After writing a program that simulates data, it is important to check that the statistical properties of the simulated (synthetic) data match the properties of the model. As a first step, you can generate a large random sample from the model distribution and compare the sample statistics to the expected
![Rank, order, and sorting](https://blogs.sas.com/content/iml/files/2024/05/orderRank2.png)
A SAS programmer was trying to implement an algorithm in PROC IML in SAS based on some R code he had seen on the internet. The R code used the rank() and order() functions. This led the programmer to ask, "What is the different between the rank and the order?
![The distribution of p-values under the null hypothesis](https://blogs.sas.com/content/iml/files/2024/05/uniformPval3-640x336.png)
A SAS statistical programmer recently asked a theoretical question about statistics. "I've read that 'p-values are uniformly distributed under the null hypothesis,'" he began, "but what does that mean in practice? Is it important?" I think data simulation is a great way to discuss the conditions for which p-values are
![Dice and the correctness of a simulation](https://blogs.sas.com/content/iml/files/2024/05/diceSim1-640x336.png)
At a recent conference in Las Vegas, a presenter simulated the sum of two dice and used it to simulate the game of craps. I write a lot of simulations, so I'd like to discuss two related topics: How to simulate the sum of two dice in SAS. This is