I'm fairly new to SAS and am working with a statistician to develop a model using PROC MCMC. It's running extremely slow and I took a look at her code to see if I can help optimize it since I have experience with Stan and pyMC3. The code has quite a few do loops, e.g., do i = 1 to 3000;
result[i] = exp(a[1] + a[2] * log2(x[i]));
end; My main experience is with Stan and pyMC3. In both of those packages many functions are vectorized. That is, the function takes a vector or matrix rather than having to operate elementwise. For example, in Stan, we could replace the do loop to get the following code: result = exp(a[1] + a[2] * log2(x)); Avoiding loops and using the vectorized form of `exp` and `log2` in Stan greatly speeds up programming. Is this also true for SAS? If so, how would one vectorize the above code? It looks like from the documentation that log2 and exp take only scalar (i.e., floating point values) and cannot work with arrays.
... View more