To make the SAS tip complete, below is a better example of using two different group variables, SEX and RACE, to produce several types of group descriptive statistics - COUNT, MIN and MAX. Note that for the SEX grouping variable, while COUNT is based on SEX, MIN and MAX are based on WEIGHT. I created RACE as the second group variable.

As I indicated, the alternative method to directly apply GROUP BY without the subquery will rearrange your dataset, which may not be wanted.

data class_r;
set sashelp.class;

if _n_ < 10 then race='White';
else if _n_ < 16 then race='Black';
else race='Other';
run;

proc sql;
create table class4 as
select a.*, b.sexn, b.minwgt, b.maxwgt, c.racen
from sashelp.class as a
left join
(select name, count(sex) as sexn, min(weight) as minwgt, max(weight) as maxwgt
from sashelp.class where sex > ' ' group by sex
) as b on a.name=b.name
left join
(select name, count(race) as racen
from class_r where race > ' ' group by race
) as c on a.name=c.name
;
quit;