Posts Tagged ‘ Efficiency ’

Finding observations that match a target value

March 18, 2015
By
Finding observations that match a target value

Imagine that you have one million rows of numerical data and you want to determine if a particular "target" value occurs. How might you find where the value occurs? For univariate data, this is an easy problem. In the SAS DATA step you can use a WHERE clause or a

The post Read more »

Tags: , ,
Posted in SAS | Comments Off

Count the number of unique rows in a matrix

June 24, 2013
By

How do you count the number of unique rows in a matrix? The simplest algorithm is to sort the data and then iterate down the rows, comparing each row with the previous row. However, this algorithm has two shortcomings: it physically sorts the data (which means that the original locations
Read more »

Tags: , ,
Posted in SAS | Comments Off

Using simulation to estimate the power of a statistical test

May 30, 2013
By
Using simulation to estimate the power of a statistical test

The power of a statistical test measures the test's ability to detect a specific alternate hypothesis. For example, educational researchers might want to compare the mean scores of boys and girls on a standardized test. They plan to use the well-known two-sample t test. The null hypothesis is that the
Read more »

Tags: , , ,
Posted in SAS | Comments Off

How to vectorize computations in a matrix language

May 15, 2013
By
How to vectorize computations in a matrix language

Last week someone posted an interesting question to the SAS/IML Support Community. The problem involved four nested DO loops and took hours to run. By transforming several nested DO loops into an equivalent matrix operation, I was able to reduce the run time to about one second. The process of
Read more »

Tags: , ,
Posted in SAS | Comments Off

Oh, those pesky temporary variables!

January 30, 2013
By
Oh, those pesky temporary variables!

The SAS/IML language secretly creates temporary variables. Most of the time programmers aren't even aware that the language does this. However, there is one situation where if you don't think carefully about temporary variables, your program will silently produce an error. And as every programmer knows, silent wrong numbers are
Read more »

Tags: , , ,
Posted in SAS | Comments Off

Generate binary outcomes with varying probability

January 16, 2013
By
Generate binary outcomes with varying probability

A while ago I saw a blog post on how to simulate Bernoulli outcomes when the probability of generating a 1 (success) varies from observation to observation. I've done this often in SAS, both in the DATA step and in the SAS/IML language. For example, when simulating data that satisfied
Read more »

Tags: , , , ,
Posted in SAS | Comments Off

Remove or keep: Which is faster?

December 5, 2012
By
Remove or keep: Which is faster?

In a recent article on efficient simulation from a truncated distribution, I wrote some SAS/IML code that used the LOC function to find and exclude observations that satisfy some criterion. Some readers came up with an alternative algorithm that uses the REMOVE function instead of subscripts. I remarked in a
Read more »

Tags: , , ,
Posted in SAS | Comments Off

Efficient acceptance-rejection simulation: Part II

November 21, 2012
By
Efficient acceptance-rejection simulation: Part II

Last week I wrote about using acceptance-rejection algorithms in vector languages to simulate data. The main point I made is that in a vector language it is efficient to generate many more variates than are needed, with the knowledge that a certain proportion will be rejected. In last week's article,
Read more »

Tags: , ,
Posted in SAS | Comments Off

Proc-x is looking for sponsors!

Dear readers, proc-x is looking for sponsors who would be willing to support the site in exchange for banner ads in the right sidebar of the site. If you are interested, please e-mail me at: tal.galili@gmail.com

Welcome!

SAS-X.com offers news and tutorials about the various SAS® software packages, contributed by bloggers. You are welcome to subscribe to e-mail updates, or add your SAS-blog to the site.

SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.