@PGStats wrote:
Assuming your data is in table toFroData, you could get those statistics with a few queries:
%let location=BANGALORE;
title "To and fro performance of &location.";
proc sql;
create table to as
select upcase(destination) as toCity, sum(totalFrt) as toFrt
from toFroData
where upcase(city) = "&location"
group by toCity;
create table fro as
select upcase(city) as froCity, sum(totalFrt) as froFrt
from toFroData
where upcase(destination) = "&location"
group by froCity;
create table want as
select
coalesce(toCity, froCity) as City ,
froFrt,
froFrt / sum(froFrt) as froPct format=percentn7.2,
toFrt,
toFrt / sum(toFrt) as toPct format=percentn7.2
from to full join fro on toCity=froCity;
select * from want;
quit;
... View more