Be the brightest light on the porch: Efficiency tips for programmers

0

Kathleen Harkins, Carolyn Maass and Mary Anne Rutkowski, from Merck Sharp and Dohme, collaborated to write T.I.P.S: Techniques and information for programming in SAS® for NESUG 2011. These three women are highly experienced programmers: Harkins has more than 20 years of experience in the pharmaceutical and aerospace industries; Maass has 13 years of experience, primarily in the clinical data setting; and Rutkowski has been programming in SAS for more than 20 years – mainly in clinical trials data analysis. They realized that even experienced users still have more to learn, so they decided to put their experience to good use – for beginners and more experienced programmers. According to Kathy Harkins, the paper presenter, all levels can apply these techniques to make their code more efficient.

(Photo at right: Mary Anne Rutkowski, left; Carolyn Maass, center; Kathy Harkins, right.)

There are five areas of efficiency covered in the paper:

  1. Read and write data selectively.
  2. Concise coding techniques.
  3. Sorting techniques.
  4. Data manipulation.
  5. Macros.

I captured some of the tips that Harkin shared in her presentation and added some of the code examples from the paper. The ladies tested their examples for run time speeds and other efficiencies. (Levels of efficiency may vary for specific situations.) Here are some examples that may seem intuitive, but you need to plan ahead:

  • Keep only necessary variables – Use the KEEP= or DROP= on the SET or MERGE statement to keep unneeded variables out of the Program Data Variable (PDV). The PDV is the storage area for variables, values and attributes.
  • Produce all subsets you require for further processing in one step to reduce the number of times a data set is read in.

  • Avoid storing subsets unnecessarily – if a subset of data is only needed for a procedure, avoid creating a separate dataset.
  • Execute only necessary statements – When “IF” conditions are mutually exclusive, use if-then-else instead AND move most likely condition to top of logic.

As many of you who have presented can attest, time often runs out before your material does. The topic of programming efficiency is quite broad. This paper covers three more topics than could be adequately covered during the presentation: sorting techniques, data manipulation and macros. Please take time to read the paper, T.I.P.S: Techniques and information for programming in SAS®. Then, write your programming tips in the comments. I'll share your tips with other users via LinkedIn and Twitter. Be sure and follow #NESUG11 on Twitter and me - @waynettetubbs.


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

Waynette Tubbs

Editor, Marketing Editorial

Waynette Tubbs is a seasoned technology journalist specializing in interviewing and writing about how leaders leverage advanced and emerging analytical technologies to transform their B2B and B2C organizations. In her current role, she works closely with global marketing organizations to generate content about artificial intelligence (AI), generative AI, intelligent automation, cybersecurity, data management, and marketing automation. Waynette has a master’s degree in journalism and mass communications from UNC Chapel Hill.

Leave A Reply

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

Back to Top