In reply to Arne Cordes.

Arne ,
You can use special encoding (fixed-length sequence) and SHAPE() function.

I noticed there are some missing value in Cholesterol ,so I fixed it again and looks like better than your result.

OUTPUT:
The MEANS Procedure
Analysis Variable : Cholesterol
group N Obs Mean Std Dev
1 627 221.9649123 43.1137738
2 627 221.9665072 43.1220553
3 627 221.9505582 43.0823468
4 627 221.9569378 43.0712286
5 627 221.9601276 43.1105645

data Units;
set Sashelp.Heart(where=(status = "Alive"));
n+1;
keep n Sex AgeAtStart Height Weight Diastolic Systolic MRW Cholesterol;
run;

proc iml;
use Units nobs nobs;
read all var {Cholesterol};
close;

start function(x) global(Cholesterol,group,mean_std);
xx=shape(x,group,0,.);
do i=1 to group;
idx=setdif(xx[i,],{.});
temp=Cholesterol[idx];
mean_std[i,1]=mean(temp);
mean_std[i,2]=std(temp);
end;
sse=sum(mean_std[,]-mean_std[><,]);
return (sse);
finish;

group=5; /* <--Change it(divide into 5 groups)*/
mean_std=j(group,2,.);

id=gasetup(3,nobs,123456789);
call gasetobj(id,0,"function");
call gasetsel(id,10,1,1);
call gainit(id,1000);

niter = 100;
do i = 1 to niter;
call garegen(id);
call gagetval(value, id);
end;
call gagetmem(mem, value, id, 1);

col_mem=shape(mem,group,0,.);

create group from col_mem;
append from col_mem;
close;

print value[l = "Min Value:"] ;
call gaend(id);
quit;

data group;
set group;
group+1;
run;
proc transpose data=group out=member(drop=_: index=(col1));
by group;
var col:;
run;

data want;
merge member(rename=(col1=n) where=(n is not missing)) Units(keep=n Cholesterol);
by n;
run;
proc means data=want mean std;
class group;
var Cholesterol;
run;