I want to find the best revenue for every year and revtype. As seen on the image, if month apr is having the best sales, then apr will come under column best_sale. If there are two months having equal highest values, then I want both of them in the best_sale column.
data year;
set similar;
array k(*) jan--dec;
do i=1 to dim(k);
do j=i to dim(k);
if k(i)=max(of k(*)) then best_sale=vname(k(i));
if best_sale=vname(k(j)) then output year;
end;
end;
drop i j;
run;
proc sort data=year nodup out=y;
by year;
run;
data best;
length cat $100.;
do until (last.year);
set y;
by year;
cat=catx(',',cat,best_sale);
end;
drop best_sale;
run;
When I'm running the above code, it does not consider revtype because the do until loop is running for year only. But I want the yearly best sale for both revtypes, "cargo" and "passenger".

