Its quite the faff, but:
proc sort data=sashelp.class out=class;
by sex;
run;
data durchschnitt2 (keep=sex age_min--height_mean);
set class;
by sex;
array results{3,4} age_min age_max age_count age_mean
weight_min weight_max weight_count weight_mean
height_min height_max height_count height_mean;
array vals{3} age weight height;
retain age_min--height_mean;
if first.sex then call missing(of results{*});
do i=1 to 3;
results{i,1}=min(results{i,1},vals{i});
results{i,2}=max(results{i,2},vals{i});
results{i,3}=sum(results{i,3},1);
results{i,4}=sum(results{i,4},vals{i});
end;
if last.sex then do;
do i=1 to 3;
results{i,4}=results{i,4} / results{i,3};
end;
output;
end;
run;
Also note the use of the code window (its the {i} above post area)
... View more