None of the above solution is a single SQL.
Question is, why is that important? Is this you real summarized data huge, and you want to avoid more than one pass of data? In that case, one could use a view approach for the SQL group by step.
And for ranking, why not use a procedure which was created to do - ranking...?
In my eyes, it is the simplest (and supported) code:
proc rank data=work.a1 out=a2 descending;
var tot_sales;
ranks rank_sales;
run;
/Linus
Oh, missed the ranks statement...
Message was edited by: Linus H
Data never sleeps