The DO Loop
Statistical programming in SAS with an emphasis on SAS/IML programs![Detect palindromes and rotational palindromes in SAS](https://blogs.sas.com/content/iml/files/2022/06/palindrome1-702x250.png)
A palindrome is a sequence of letters that is the same when read forward and backward. In brief, if you reverse the sequence of letters, the word is unchanged. For example, 'mom' and 'racecar' are palindromes. You can extend the definition to phrases by removing all spaces and punctuation marks
![The effect of weight functions in a robust regression method](https://blogs.sas.com/content/iml/files/2022/06/RRegWeights4-640x336.png)
M estimation is a robust regression technique that assigns a weight to each observation based on the magnitude of the residual for that observation. Large residuals are downweighted (assigned weights less than 1) whereas observations with small residuals are given weights close to 1. By iterating the reweighting and fitting
![Weights for residuals in robust regression](https://blogs.sas.com/content/iml/files/2022/05/RRWeightingFuncs1-480x336.png)
An early method for robust regression was iteratively reweighted least-squares regression (Huber, 1964). This is an iterative procedure in which each observation is assigned a weight. Initially, all weights are 1. The method fits a least-squares model to the weighted data and uses the size of the residuals to determine
![Random assignment of subjects to groups in SAS](https://blogs.sas.com/content/iml/files/2022/05/RandGroups2-640x336.png)
A common question on SAS discussion forums is how to randomly assign observations to groups. An application of this problem is assigning patients to cohorts in a clinical trial. For example, you might have 137 patients that you want to randomly assign to three groups: a control group, a group
![How much does a bootstrap estimate depend on the random number stream?](https://blogs.sas.com/content/iml/files/2022/05/BootSeed3-640x336.png)
Many modern statistical techniques incorporate randomness: simulation, bootstrapping, random forests, and so forth. To use the technique, you need to specify a seed value, which determines pseudorandom numbers that are used in the algorithm. Consequently, the seed value also determines the results of the algorithm. In theory, if you know
![The balanced bootstrap in SAS](https://blogs.sas.com/content/iml/files/2022/05/BalBoot6-640x336.png)
I have previously blogged about ways to perform balanced bootstrap resampling in SAS. I recently learned about an easier way: Since SAS/STAT 14.2 (SAS 9.4M4), the SURVEYSELECT procedure has supported balanced bootstrap sampling. This article reviews balanced bootstrap sampling and shows how to use the METHOD=BALBOOT option in PROC SURVEYSELECT