### About this blog

Rick Wicklin, PhD, is a distinguished researcher in computational statistics at SAS and is a principal developer of PROC IML and SAS/IML Studio. This blog focuses on statistical programming. It discusses statistical and computational algorithms, statistical graphics, simulation, efficiency, and data analysis. Rick is author of the books

*Statistical Programming with SAS/IML Software*and*Simulating Data with SAS*.

Follow @RickWicklin on Twitter.

**Do you have a SAS programming question?**Assistance is available! Ask SAS/IML questions at the SAS/IML Support Community. For other SAS issues, visit the SAS Support Communities.### Subscribe to this blog

### Tags

9.3 9.4 9.22 12.1 12.3 13.1 13.2 Bootstrap and Resampling Ciphers Conferences Data Analysis Efficiency File Exchange Getting Started GTL Heat maps History IMLPlus Just for Fun Math Matrix Computations Numerical Analysis Optimization R Reading and Writing Data SAS/IML Studio SAS Global Forum SAS Programming Simulation Statistical Graphics Statistical Programming Statistical Thinking Strings Tips and Techniques vectorization Video### Archives

## Finding observations that satisfy multiple conditions: The LOC-ELEMENT technique

A common task in data analysis is to locate observations that satisfy multiple criteria. For example, you might want to locate all zip codes in certain counties within specified states. The SAS DATA step contains the powerful WHERE statement, which enables you to extract a subset of data that satisfy […]

Post a Comment ## An easy way to clear your SAS titles

Did you know that if you have set multiple titles in SAS, that there is an easy way to remove them? For example, suppose that you've written the following statements, which call the TITLE statement to set three titles: title "A Great Big Papa Title"; title2 "A Medium-sized Mama Title"; […]

Post a Comment ## Sum a series in SAS

A customer asked: How do we go about summing a finite series in SAS? For example, I want to compute for various integers n ≥ 3. I want to output two columns, one for the natural numbers and one for the summation of the series. Summations arise often in statistical […]

Post a Comment ## Writing data in chunks: Does the chunk size matter?

I often blog about the usefulness of vectorization in the SAS/IML language. A one-sentence summary of vectorization is "execute a small number of statements that each analyze a lot of data." In general, for matrix languages (SAS/IML, MATLAB, R, ...) vectorization is more efficient than the alternative, which is to […]

Post a Comment ## Avoid loops, avoid the APPLY function, vectorize!

Last week I received a message from SAS Technical Support saying that a customer's IML program was running slowly. Could I look at it to see whether it could be improved? What I discovered is a good reminder about the importance of vectorizing user-defined modules. The program in this blog […]

Post a Comment ## Detect empty parameters that are passed to a SAS/IML module

A SAS/IML programmer asked a question on a discussion forum, which I paraphrase below: I've written a SAS/IML function that takes several arguments. Some of the arguments have default values. When the module is called, I want to compute some quantity, but I only want to compute it for the […]

Post a Comment ## The relationship between skewness and kurtosis

In my book Simulating Data with SAS, I discuss a relationship between the skewness and kurtosis of probability distributions that might not be familiar to some statistical programmers. Namely, the skewness and kurtosis of a probability distribution are not independent. If κ is the full kurtosis of a distribution and […]

Post a Comment ## IF-THEN logic with matrix expressions

In the SAS DATA step, all variables are scalar quantities. Consequently, an IF-THEN/ELSE statement that evaluates a logical expression is unambiguous. For example, the following DATA step statements print "c=5 is TRUE" to the log if the variable c is equal to 5: if c=5 then put "c=5 is TRUE"; […]

Post a Comment ## What is an empty matrix?

At the beginning of my book Statistical Programming with SAS/IML Software I give the following programming tip (p. 25): Do not confuse an empty matrix with a matrix that contains missing values or with a zero matrix. An empty matrix has no rows and no columns. A matrix that contains […]

Post a Comment ## Finding matrix elements that satisfy a logical expression

A common task in SAS/IML programming is finding elements of a SAS/IML matrix that satisfy a logical expression. For example, you might need to know which matrix elements are missing, are negative, or are divisible by 2. In the DATA step, you can use the WHERE clause to subset data. […]

Post a Comment