That's fine but what if dont want to keep changing the first and last values. may be i just want my code to work for all datasets thrown at it.
data test3;
set tr_test2;
/*keep managers;*/
array a_mngrs {*} _NUMERIC_;
if _N_=1 then index=1;
do i=1 to &n_accounts.;
if min(of a_mngrs{*}) lt 50 then do;
do j=1 to dim(a_mngrs);
if a_mngrs{index} lt 50 then do;
a_mngrs{index}=a_mngrs{index}+1;
managers=vname(a_mngrs{index});
j=dim(a_mngrs); /* Exit loop on j*/
output;
end;
/* Probably a better way to do this */
index=mod(index+1,dim(a_mngrs));
if index=0 then index=dim(a_mngrs);
end;
end;
else do;
i=&naccounts.; /* Exit loop on i */
end;
end;
run;
You're welcome. There is still a typo you probably noticed
else do;
i=&n_accounts.; /* Exit loop on i */
end;
I forgot the underscore in &n_accounts.
Also, you can uncomment the keep that i commented for debug.
Explain the stopping condition a bit more ... how does count reach 50?
If a solution involved sorting (and yet still got the answer you wanted) is that feasible or is your data set too large?
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.