proc sql;
create table max1 as select id , max(x1) as max from aaa group by id;
create table max2 as select id ,x1, max(x2) as max from bbb group by id,x1;
quit;
proc sort data=aaa;
by id;
run;
proc sort data=aaa;
by id x1;
run;
data max1;
set aaa;
by id;
if last.id;
run;
data max2;
set bbb;
by id x1;
if last.x1;
run;