The DO Loop
Statistical programming in SAS with an emphasis on SAS/IML programs![Specify formats when you write vectors to a data set](https://blogs.sas.com/content/iml/files/2014/06/t_mattribformat.png)
Sometimes you have data in SAS/IML vectors that you need to write to a SAS data set. By default, no formats are associated with the variables that you create from SAS/IML vectors. However, some variables (notably dates, times, and datetimes) should have formats associated with the data values. You can
![An easy way to generate a vector of letters](https://blogs.sas.com/content/iml/files/2014/05/t_letters.png)
A little-known but useful feature of SAS/IML 12.3 (which was released with SAS 9.4) is the ability to generate a vector of lowercase or uppercase letters by using the colon operator (:). Many SAS/IML programmers use the colon operator to generate a vector of sequential integers: proc iml; x =
![Tips for concatenating strings in SAS/IML](https://blogs.sas.com/content/iml/files/2014/05/t_concat1.png)
Last week, as part of an article on how spammers generate comments for blogs, I showed how to generate random messages by using the CATX function in the DATA step. In that example, the strings were scalar quantities, but you can also concatenate vectors of strings in the SAS/IML language.
![How to create a string of a specified length in SAS/IML](https://blogs.sas.com/content/iml/files/2017/01/AdvancedAnalytics-1.png)
In my recent post on how to understand character vectors in SAS/IML, I left out an important topic: How can you allocate a character vector of a specified length? In this article, "length" means the maximum number of characters in an element, not the number of elements in a vector.
![This article is actually fastidious: How spammers generate random comments for blogs](https://blogs.sas.com/content/iml/files/2014/05/t_spamcomments.png)
Last week Chris Hemedinger posted an article about spam that is sent to SAS blogs and discussed how anti-spam software helps to block spam. No algorithm can be 100% accurate at distinguishing spam from valid comments because of the inherent trade-off between specificity and sensitivity in any statistical test. Therefore,
![Blanks and lengths: Understanding SAS/IML character vectors](https://blogs.sas.com/content/iml/files/2014/05/t_charstorage.png)
SAS programmers are probably familiar with how SAS stores a character variable in a data set, but how is a character vector stored in the SAS/IML language? Recall that a character variable is stored by using a fixed-width storage structure. In the SAS DATA step, the maximum number of characters