Hi Mkeintz, I'm getting closer. I did not know about the dif function, so that is very helpful! I needed to adapt your code, because I was simplifying my data for the purpose of my question, and I actually have 24 correlations. Here is my code now: data results_cumcorr;
set results;
cum_y + y;
cum_ysq + y**2;
array x x01 - x24;
array cum_x cum_x01 - cum_x24;
array cum_xsq cum_xsq01 - cum_xsq24;
array cum_cov cov_01 - cov_24;
array cum_r cumr_01 -cumr_24; array con con_01 - con_24;
do over x;
cum_x + x;
cum_xsq + x**2;
cum_cov + y*x;
cum_r = ((_n_*cum_cov)-(cum_x*cum_y))/sqrt(((_n_*cum_xsq)-cum_x**2)*((_n_*cum_ysq)-cum_y**2)); if _n_>1 and dif(cum_r)<=.01 then con=1; else con=0;
end;
run; With this new line of code, I have 24 new variables that show me whether convergence has been met (1) or not (0). I thought about doing a proc freq to figure out when convergence has been met for each variable, but the problem is that it doesn't necessarily converge the first rep for which con=1. For example, in this instance, it appeared that convergence had been met but then the change in correlation went above .01 for rep 203. If I had just asked for it to stop when con=1, then it would not have caught that instance. (And I'd have the same issue with doing a proc freq) rep con 200 1 201 1 202 1 203 0 204 1 Is there a way for me to ask SAS to output the last rep for which con=0? Thank you!
... View more