Posts Tagged ‘ Getting Started ’

Writing data in chunks: Does the chunk size matter?

March 9, 2015
By
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 […] The post Writing data in chunks: Does the chunk size matter? appeared first on The DO Loop.

Read more »

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 […] The post Avoid loops, avoid the APPLY function, vectorize! appeared first on The DO Loop.

Read more »

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

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

Read more »

The relationship between skewness and kurtosis

January 28, 2015
By
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 […]

Read more »

IF-THEN logic with matrix expressions

January 26, 2015
By
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"; […]

Read more »

What is an empty matrix?

January 22, 2015
By
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 […]

Read more »

Finding matrix elements that satisfy a logical expression

January 20, 2015
By
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. […]

Read more »

Compute the kth smallest data value in SAS

January 7, 2015
By
Compute the kth smallest data value in SAS

A SAS programmer recently posted a question to the SAS/IML Support Community about how to compute the kth smallest value in a vector of numbers. In the DATA step, you can use the SMALLEST function to find the smallest value in an array, but there is no equivalent built-in function […]

Read more »

Elementwise minimum and maximum operators

December 15, 2014
By
Elementwise minimum and maximum operators

Like most programming languages, the SAS/IML language has many functions. However, the SAS/IML language also has quite a few operators. Operators can act on a matrix or on rows or columns of a matrix. They are less intuitive, but can be quite powerful because they enable you perform computations without […]

Read more »

The direct product (Kronecker product) in SAS

December 8, 2014
By
The direct product (Kronecker product) in SAS

There are many ways to multiply scalars, vectors, and matrices, but the Kronecker product (also called the direct product) is multiplication on steroids. The Kronecker product looks scary, but it is actually simple. The Kronecker product is merely a way to pack multiples of a matrix B into a block […]

Read more »


Subscribe

Email:

  Subscribe