The DO Loop
Statistical programming in SAS with an emphasis on SAS/IML programs![Trap and map: Trapping invalid values](https://blogs.sas.com/content/iml/files/2017/01/ProgrammingTips-2.png)
Finite-precision computations can be tricky. You might know, mathematically, that a certain result must be non-negative or must be within a certain interval. However, when you actually compute that result on a computer that uses finite-precision, you might observe that the value is slightly negative or slightly outside of the
![Density, CDF, and quantiles for the Poisson-binomial distribution PDF of the Poisson-binomial distribution](https://blogs.sas.com/content/iml/files/2020/09/PoisBinomPDF4-640x336.png)
When working with a probability distribution, it is useful to know how to compute four essential quantities: a random sample, the density function, the cumulative distribution function (CDF), and quantiles. I recently discussed the Poisson-binomial distribution and showed how to generate a random sample. This article shows how to compute
![The Poisson-binomial distribution](https://blogs.sas.com/content/iml/files/2020/09/PoisBinom2-640x336.png)
The Poisson-binomial distribution is a generalization of the binomial distribution. For the binomial distribution, you carry out N independent and identical Bernoulli trials. Each trial has a probability, p, of success. The total number of successes, which can be between 0 and N, is a binomial random variable. The distribution
![Working with recurrence relations in SAS](https://blogs.sas.com/content/iml/files/2017/01/ProgrammingTips-2.png)
Many textbooks and research papers present formulas that involve recurrence relations. Familiar examples include: The factorial function: Set Fact(0)=1 and define Fact(n) = n*Fact(n-1) for n > 0. The Fibonacci numbers: Set Fib(0)=1 and Fib(1)=1 and define Fib(n) = Fib(n-1) + Fib(n-2) for n > 1. The binomial coefficients (combinations
![Regression with inequality constraints on parameters](https://blogs.sas.com/content/iml/files/2020/09/restrictedReg3-614x336.png)
A previous article discussed how to solve regression problems in which the parameters are constrained to be a specified constant (such as B1 = 1) or are restricted to obey a linear equation such as B4 = –2*B2. In SAS, you can use the RESTRICT statement in PROC REG to
![Restricted least squares regression in SAS](https://blogs.sas.com/content/iml/files/2020/09/restrictedReg3-614x336.png)
A data analyst recently asked a question about restricted least square regression in SAS. Recall that a restricted regression puts linear constraints on the coefficients in the model. Examples include forcing a coefficient to be 1 or forcing two coefficients to equal each other. Each of these problems can be