Rick, Why not use my start-end index skill which avoid to read table many times .

proc sort data=sashelp.cars out=cars;
by Origin Type;
run;

proc iml;
use cars nobs nobs;
read all var {Origin Type MPG_City};
close ;
x=catx(' ',Origin,Type);
start_end=t(loc(x^=t({' '}||remove(x,nobs)))) ||
t(loc(x^=t(remove(x,1)||{' '})));

O=Origin[start_end[,1]];
T=Type[start_end[,1]];
Stats=j(nrow(start_end),2,.);
Stats[,1]=start_end[,2]-start_end[,1]+1;
do i=1 to nrow(start_end);
Stats[i,2]=mean(MPG_City[start_end[i,1]:start_end[i,2]]);
end;

print O T Stats[colname={"N" "Mean"}];
quit;