SAS

Blogs on the SAS software

Avoid loops, avoid the APPLY function, vectorize!

March 2, 2015
By
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 […]

Read more »

Plotting multiple time series in SAS/IML (Wide to Long, Part 2)

February 27, 2015
By
Plotting multiple time series in SAS/IML (Wide to Long, Part 2)

I recently wrote about how to overlay multiple curves on a single graph by reshaping wide data (with many variables) into long data (with a grouping variable). The implementation used PROC TRANSPOSE, which is a procedure in Base SAS. When you program in the SAS/IML language, you might encounter data […]

Read more »

Plotting multiple series: Transforming data from wide to long

February 25, 2015
By
Plotting multiple series: Transforming data from wide to long

Data. To a statistician, data are the observed values. To a SAS programmer, analyzing data requires knowledge of the values and how the data are arranged in a data set. Sometimes the data are in a "wide form" in which there are many variables. However, to perform a certain analysis […]

Read more »

Complete cases: How to perform listwise deletion in SAS

February 23, 2015
By
Complete cases: How to perform listwise deletion in SAS

SAS procedures usually handle missing values automatically. Univariate procedures such as PROC MEANS automatically delete missing values when computing basic descriptive statistics. Many multivariate procedures such as PROC REG delete an entire observation if any variable in the analysis has a missing value. This is called listwise deletion or using […]

Read more »

Monitor the progress of a long-running SAS/IML program

February 18, 2015
By
Monitor the progress of a long-running SAS/IML program

When you have a long-running SAS/IML program, it is sometimes useful to be able to monitor the progress of the program. For example, suppose you need to computing statistics for 1,000 different data sets and each computation takes between 5 and 30 seconds. You might want to output a message […]

Read more »

Friends don’t let friends concatenate results inside a loop

February 16, 2015
By
Friends don’t let friends concatenate results inside a loop

Friends have to look out for each other. Sometimes this can be slightly embarrassing. At lunch you might need to tell a friend that he has some tomato sauce on his chin. Or that she has a little spinach stuck between her teeth. Or you might need to tell your […]

Read more »

Binary heart in SAS

February 11, 2015
By
Binary heart in SAS

The xkcd comic often makes me think and laugh. The comic features physics, math, and statistics among its topics. Many years ago, the comic showed a "binary heart": a grid of binary (0/1) numbers with the certain numbers colored red so that they formed a heart. Some years later, I […]

Read more »

Creating an array of matrices

February 9, 2015
By
Creating an array of matrices

The SAS DATA step supports multidimensional arrays. However, matrices in SAS/IML are like mathematical matrices: they are always two dimensional. In simulation studies you might need to generate and store thousands of matrices for a later statistical analysis of their properties. How can you accomplish that unless you can create […]

Read more »

Migrating code pieces to GitHub

February 5, 2015
By
Migrating code pieces to GitHub

One of the original reasons for this blog was to keep track of my SAS code as well as its relevant context. That was the mindset when I was a SAS analyst, but now working in professional software company, using the right tool for versioning, col...

Read more »

Specify the order of variables at run time in SAS

February 4, 2015
By
Specify the order of variables at run time in SAS

In SAS, the order of variables in a data set is usually unimportant. However, occasionally SAS programmers need to reorder the variables in order to make a special graph or to simplify a computation. Reordering variables in the DATA step is slightly tricky. There are Knowledge Base articles about how […]

Read more »


Subscribe

Email:

  Subscribe