WaltSmith posted:
>probably more important than if then / else vs select when (I've done no testing comparing these) - but standard advice to optimize performance is to test the most common condition first, second most common second, etc.
>Easily seen using the reverse case - for a dataset with 10M rows, if the most common case is listed last in a sequence of 100 tests, then the most common case requires 100 * 10M tests. If listed first it requires 1 * 10M tests.
...
Hi, Walt,
Your suggestion may have been true some time ago, but no longer.
We don't have to argue about it. Below code shows that at least on my two year old PC, the CPU time saving by re-arranging the if conditions is not big enough to make the elapsed time difference at all, even when we force sas to load the input data on the memory.
Notice that my input data set has 10M obs with only 2 vars, which is unrealistically conservative. In reality, there will be more variables and this will only increase the time SAS spends on I/O instead of evaluating logical expressions or branching.
Conclusion? It does help to order your if conditions so that the most common cases listed first, but only a *little* bit, if any.
(Code was too long for this forum: posted on sas-l:
http://www.listserv.uga.edu/cgi-bin/wa?A2=ind1009d&L=sas-l&D=1&O=D&P=18636)