SAS Data Step Debugger: Your liberator from logic errors

0

“I really wish someone had shown me this function in SAS sooner, because it’s saved me a ton of time and effort,” said Brandi Rhoads as she opened her presentation at the Western Users of SAS Software (WUSS) conference in San Francisco.  

In her job at the Economic and Statistical Research Bureau of the Franchise Tax Board in Sacramento, Rhoads programmed a micro-simulation model of California state income taxes, a massive data step that mimics all of the calculations in state tax policy to enable modeling of alternate policies using a weighted sample of tax returns as her input data set.

In all, this involves almost 800 lines of code and when logic errors occur (meaning the log contains no errors because all the syntax is correct, but the lines of code don’t process as the programmer intended), it’s a giant headache to figure out where things went wrong. Then Rhoads discovered the data step debugger – a simple method that allowed her to execute her data step code systematically to identify logic errors.

But first things first, what is the debugger? Rhoads broke it down neatly – it’s an interactive troubleshooting tool in Base SAS that:

  • Allows execution of the data step line-by-line, one observation at a time.
  • When enabled a new window pops up for execution of the data step. From this screen you can execute individual lines of code, view values of a variable at any point in execution, and set conditions for execution.  
  • Allows for systematic detection of logic errors.

To execute the debugger, simply add the Debug option to data step and submit code.

Two functions within the debugger are key: Examine and Watch. For step-by-step instructions for using these functions, examples and more, check out Rhoads' paper.


These code examples are provided as is, without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.

Share

About Author

Anne-Lindsay Beall

Editor-in-Chief, sascom magazine

Anne-Lindsay Beall is Editor-in-Chief of sascom magazine, Editor of the Customer Intelligence Knowledge Exchange at SAS, and Editor of the SAS Retail News. She has developed a comprehensive portfolio of business and marketing communications during her career spanning 14 years of magazine and marketing work. You can find her on Twitter: @annelindsayb or on LinkedIn at: www.linkedin.com/in/annelindsaybeall

Related Posts

Leave A Reply

Back to Top