Blog Archives

Eight tips to make your simulation run faster

June 6, 2012
By
Eight tips to make your simulation run faster

"Help! My simulation is taking too long to run! How can I make it go faster?" I frequently talk with statistical programmers who claim that their "simulations are too slow" (by which they mean, "they take too long"). They suspect that their program is inefficient, but they aren't sure why. [...]

Read more »

Rename many variables that have numerical suffixes and a common prefix

June 4, 2012
By
Rename many variables that have numerical suffixes and a common prefix

I recently read a blog post in which a SAS user had to rename a bunch of variables named A1, A2,..., A10, such as are contained in the following data set: /* generate data with variables A1-A10 */ data A; array A[10] A1-A10 (1); do i = 1 to 10; [...]

Read more »

An easy way to define a library of user-defined functions

May 31, 2012
By
An easy way to define a library of user-defined functions

In the SAS/IML language, a user-defined function or subroutine is called a module. Modules are used to extend the capability of the SAS/IML language. In my blog posts, I usually define a module in a PROC IML session and then immediately use it. However, sometimes it is useful to store [...]

Read more »

Did you know that PROC IML automatically loads certain modules?

May 29, 2012
By
Did you know that PROC IML automatically loads certain modules?

In the SAS/IML language, a user-defined function or subroutine is called a module. Modules are used to extend the capability of the SAS/IML language. Usually you need to explicitly load modules before you use them, but there are two cases where PROC IML loads a module automatically. Modules in IMLMLIB [...]

Read more »

Compute statistics for each row by using subscript operators

May 23, 2012
By
Compute statistics for each row by using subscript operators

In a previous blog, I showed how to use SAS/IML subscript reduction operators to compute the location of the maximum values for each row of a matrix. The subscript reduction operators are useful for computing simple statistics for each row (or column) of a numerical matrix. If x is a [...]

Read more »

For each observation, find the variable that contains the minimum value

May 21, 2012
By
For each observation, find the variable that contains the minimum value

The other day I encountered an article in the SAS Knowledge Base that shows how to write a macro that "returns the variable name that contains the maximum or minimum value across an observation." Some people might say that the macro is "clever." I say it is complicated. This is [...]

Read more »

The curious case of random eigenvalues

May 16, 2012
By
The curious case of random eigenvalues

I've been a fan of statistical simulation and other kinds of computer experimentation for many years. For me, simulation is a good way to understand how the world of statistics works, and to formulate and test conjectures. Last week, while investigating the efficiency of the power method for finding dominant [...]

Read more »

How to read data set variables into SAS/IML vectors

May 14, 2012
By
How to read data set variables into SAS/IML vectors

One of the first skills that a beginning SAS/IML programmer learns is how to read data from a SAS data set into SAS/IML vectors. (Alternatively, you can read data into a matrix). The beginner is sometimes confused about the syntax of the READ statement: do you specify the names of [...]

Read more »

The power method: compute only the largest eigenvalue of a matrix

May 9, 2012
By
The power method: compute only the largest eigenvalue of a matrix

When I was at SAS Global Forum last week, a SAS user asked my advice regarding a SAS/IML program that he wrote. One step of the program was taking too long to run and he wondered if I could suggest a way to speed it up. The long-running step was [...]

Read more »

Checking your answers: Are computed values close to the true values?

May 7, 2012
By
Checking your answers: Are computed values close to the true values?

In statistical programming, I often test a program by running it on a problem for which I know the correct answer. I often use a single expression to compute the maximum value of the absolute difference between the vectors: maxDiff = max( abs( z-correct ) ); /* largest absolute difference [...]

Read more »


Subscribe

Email:

  Subscribe