Are there best practices for SAS programs? How can you make them efficient?
Does it really matter if a program takes .3 seconds or .10 seconds to run?
Some code that I have seen in the last two days points to the fact that efficiencies in SAS code (or Java / C+ / Fortran :) for that matter) should be the objective of the programmer.
Here are two things I noticed this week:
- Missing RUN Statements
run; on the Proc Sort prior to the Proc Univariate/Means/Freq/etc isn't a requirement. The program will handle both. HOWEVER, this isn't considered a good strategy.
- multiple data statements that could be combined
So you have three data statements in a row, processing the same data table. Is all that really necessary? I combined two yesterday and reduced processing time from .3 to .1 seconds. Big Deal? Maybe not - but consider this processing happening for 10,000 different data tables - now you are talking a total change from 50 MINUTES to 16 MINUTES ... SUPER BIG DEAL