Tried, tested and true -- I’m sure you already practice some, if not all, of these efficient techniques to save resources. I recently shared these 10 techniques with the Wisconsin Illinois SAS users group in Milwaukee. The conference ran smoothly under the incredibly able guidance of Dr. LeRoy Bessler. I’ll blog about my conference experience in a separate post.
In this blog, I’ve tried to summarize the 10 efficiencies for a quick read. For more in depth reading, here’s a link to the presentation with code examples and valuable resource statistics to compare and contrast.
CPU Saving Techniques - Make room in your brain for the important stuff
1. CPU Saving – Boiling down or reducing your data
The positioning of the subsetting IF can substantially reduce/increase CPU time.
2. CPU Saving – Conditional processing
Much like there are many ways to get results with SAS, there are several techniques for conditional processing. You can use IF statements or IF-THEN/ELSE or SELECT-WHEN. Find out the difference in resource statistics for technique.
3. CPU Saving – Do not reduce the length of numeric variables
Talk of numbers has everyone breaking out into war. I’m sure you know that reducing numeric length can reduce precision. But did you know that this also compromises CPU. More CPU time is needed to expand the reduced number to its full 8 bytes in the PDV.
4. I/O Saving – Reduce multiple passes through data
5. I/O Saving – Modify variable attributes
If all you need to do is change variable attributes, then consider using PROC DATASETS over the data step. For attributes other than variable index DATASETS saves you valuable I/O. It only processes the header portion of the SAS data set, while the data step processes the entire dataset.
6. I/O Saving – Process only necessary observations
7. I/O Saving – Process only necessary variables
8. Space Saving – Store as character data
9. Memory Saving – Use the BY statement instead of the CLASS
BY-group processing holds only one BY group in memory at a time. The CLASS statement accumulates aggregates for all CLASS groups simultaneously in memory.
10. Programmer Time Saving
To wrap up, I’m sure you already employ several of these practices. I do hope you find this post useful and a helpful reminder for the next time you’re considering resource efficiency in your SAS program. I look forward to hearing from you. What efficiencies do you practice?
photo credit: anna // attribution: creative commons