In reply to ChrisNZ.

Yes, this entire article is about the inefficiency of recursion. I explain multiple times why I don't recommend recursive code. Furthermore, if you want to compute some numerical quantity in SAS, don't perform the computation by using the macro facility, which is designed to generate text. Using %EVAL to add numbers that are represented as strings is extremely inefficient. Instead, use the DATA step or PROC IML or some other method that is intended for numerical computations.