Jedi SAS Tricks: 5 Ways to Make Your SAS Code Run Faster

This post was kindly contributed by SAS Users - go there to comment and to read the full post.

I’ll admit it – I’m often impatient while waiting for results, so my code needs to run as fast as possible! In this video, I show you how you can get faster results, too.

I’ll demonstrate several different techniques that produce identical results, and compare processing speeds. For a more robust assessment, I’ll test the techniques while reading from both SAS data sets and database tables. Analysis of the results clearly shows that when the techniques produce identical results, these choices usually produce faster run times:

  1. Use a WHERE statement instead of a subsetting IF statement.
  2. Use the KEEP= dataset option on input data sets instead of a KEEP statement.
  3. Should I use SQL or DATA step?
    • If producing a single result, use SQL.
    • If producing multiple results, use the DATA step.
  4. If your process is CPU bound:
    • If you have access to CAS, run it in CAS.
    • Otherwise, refactor in DS2.

The programs I used to create the video are available for download from GitHub if you want to experiment.

Until next time, may the SAS be with you!
Mark

Jedi SAS Tricks: 5 Ways to Make Your SAS Code Run Faster was published on SAS Users.

This post was kindly contributed by SAS Users - go there to comment and to read the full post.