Here's another code-based way. It's not as short and sweet, but it's versatile. You just need to modify the top portion to set the macro variables to your data and column names.
[pre]
/* replace these values with your data/columns */
%let data=SASHELP.PRDSALE;
%let report=PRODUCT;
%let measure=ACTUAL;
%let measureformat=%str(format=DOLLAR12.2); /* to retain measure format in report */
%let stat=SUM; /* or use MEAN, for average */
%let n=50; /* max values to report per category */
%let category=COUNTRY;
title Top PRODUCTs based on ACTUAL Sales in each COUNTRY;
footnote Generated on &SYSDATE;
/* summarize the data across a category and store */
/* the output in an output data set */
proc means data=&data &stat noprint;
var &measure;
class &category &report;
output out=summary &stat=&measure &category /levels;
run;
/* store the value of the measure for ALL rows and
/* the row count into a macro variable for use */
/* later in the report */
proc sql noprint;
select &measure,_FREQ_ into :overall,:numobs
from summary where _TYPE_=0;
select count(distinct &category) into :categorycount from summary;
quit;
/* sort the results so that we get the TOP values */
/* rising to the top of the data set */
proc sort data=work.summary out=work.topn;
where _type_>2;
by &category descending &measure;
run;
/* Pass through the data and output the first N */
/* values for each category */
data topn;
length rank 8;
label rank="Rank";
set topn;
by &category descending &measure;
if first.&category then rank=0;
rank+1;
if rank le &n then output;
run;
/* Create a report listing for the top values in each category */
footnote2 "&stat of &measure for ALL values of &report: &overall (&numobs total rows)";
proc report data=topn;
columns &category rank &report &measure;
define &category /group;
define rank /display;
define &measure / analysis &measureformat;
run;
quit;
[/pre]
Chris