Just a small piece of the puzzle, in case it helps ... If the ending vlaue of 5 is not hard-coded, presumably you actually have something equivalent to: %do i1=1 %to &i1_max.; %do i2=1 %to &i2_max.; You could get the proper number of loops with something along these lines: %do i=1 %to &i1_max.*&i2_max.*&i3_max.; Sometimes having the proper number of loops is sufficient, sometimes not.
... View more