The DO Loop
Statistical programming in SAS with an emphasis on SAS/IML programs![The method of moments: A smart way to choose initial parameters for MLE Histogram of data overlaid with a beta density curve, fitted by maximum likelihood estimation](https://blogs.sas.com/content/iml/files/2017/11/methodmoments0-640x336.png)
When you run an optimization, it is often not clear how to provide the optimization algorithm with an initial guess for the parameters. A good guess converges quickly to the optimal solution whereas a bad guess might diverge or require many iterations to converge. Many people use a default value
![Compute the CDF and quantiles of discrete distributions Beta-binomial cumulative distribution](https://blogs.sas.com/content/iml/files/2017/11/betabinom4-640x336.png)
A statistical programmer read my article about the beta-binomial distribution and wanted to know how to compute the cumulative distribution (CDF) and the quantile function for this distribution. In general, if you know the PDF for a discrete distribution, you can also compute the CDF and quantile functions. This article
![Simulate data from the beta-binomial distribution in SAS Beta-binomial distribution and expected values in SAS](https://blogs.sas.com/content/iml/files/2017/11/betabinom1-640x336.png)
This article shows how to simulate beta-binomial data in SAS and how to compute the density function (PDF). The beta-binomial distribution is a discrete compound distribution. The "binomial" part of the name means that the discrete random variable X follows a binomial distribution with parameters N (number of trials) and
![Catch run-time errors in SAS/IML programs](https://blogs.sas.com/content/iml/files/2017/01/ProgrammingTips-2.png)
Did you know that a SAS/IML function can recover from a run-time error? You can specify how to handle run-time errors by using a programming technique that is similar to the modern "try-catch" technique, although the SAS/IML technique is an older implementation. Preventing errors versus handling errors In general, SAS/IML
![A tip for debugging SAS/IML modules: The PAUSE statement The PAUSE statement as a debugging tool in SAS/IML Studio](https://blogs.sas.com/content/iml/files/2017/11/pause3-496x336.png)
Debugging is the bane of every programmer. SAS supports a DATA step debugger, but that debugger can't be used for debugging SAS/IML programs. In lieu of a formal debugger, many SAS/IML programmers resort to inserting multiple PRINT statements into a function definition. However, there is an easier way to query
![How to format rows of a table in SAS](https://blogs.sas.com/content/iml/files/2017/01/ProgrammingTips-2.png)
A SAS programmer wanted to display a table in which the rows have different formats. An example is shown below. The programmer wanted columns that represent statistics and rows that represent variables. She wanted to display formats (such as DOLLAR) for some variables—but only for certain statistics. For example, the