I previosly made a programme that sorts a large group of data into 10 equal parts , weighted by theyre values for feild A .
I have been trying to recreate it so that it works for any amount of equal parts .
here is my code for sorting the groups .
/*setting = 10 as an example*/
%LET n = 10;
data Weighted ;
set OGDATA;
i=1;
%LET GroupNo=&i;
Format Group $10.;
Do while (i<&n);
if Cumulative_A < (((i-1)/&n)*(Total_A))Then Group = "Group &GroupNo";
put i=;
keep Total_A Cumulative_A Group A ;
i+1;
end;
output;
Run;
proc summary data=Weighted ;
by Group ;
var Total_A ;
output out=SummaryBand sum= ;
run;
run ;
PROBLEMS :
code doesnt split the data correctly , it only gives G