2

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

 2 years ago
source link: https://blogs.sas.com/content/sgf/2021/09/30/5-ways-to-make-your-sas-code-run-faster/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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

0

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

About Author

SAS Jedi

SAS Jedi
Principal Technical Training Consultant

Mark Jordan (a.k.a. SAS Jedi) grew up in northeast Brazil as the son of Baptist missionaries. He served 20 years as a US Navy submariner, pursuing his passion for programming as a hobby. Upon retiring from the Navy in 1994, he turned his hobby into a dream job and has been a SAS programmer ever since.

Mark writes and teaches a broad spectrum of SAS Foundation programming classes, and his book, "Mastering the SAS® DS2 Procedure: Advanced Data Wrangling Techniques" is now in its second edition.

When he isn’t writing, teaching, or posting “Jedi SAS Tricks” here on the SAS Learning Post, Mark enjoys playing with his grand and great-grandchildren, hanging out at the beach and reading science fiction novels. His secret obsession is flying toys – kites, rockets, drones – and though he usually tries to convince Lori that they are for the grandkids, she isn't buying it. Mark lives in historic Williamsburg, VA with his wife, Lori, and Stella, their cat. To connect with Mark, check out his SAS Press Author page, follow him on Twitter @SASJedi or connect on Facebook or LinkedIn.

Leave A Reply Cancel Reply

Save my name, email, and website in this browser for the next time I comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK