data have;
input Region $ Customer_ID Method & $10.;
cards;
USA 1 By Hand
USA 1 Shipping
USA 1 By Hand
USA 1 By Hand
USA 2 By Hand
USA 2 Shipping
USA 2 Express
USA 2 Express
TW 2 Express
TW 2 Express
TW 2 Express
HK 1 By Hand
HK 2 By Hand
HK 3 By Hand
;
data want;
if _n_=1 then do;
if 0 then set have;
declare hash c();
c.definekey('Customer_ID');
c.definedone();
declare hash m();
m.definekey('Method');
m.definedone();
end;
set have;
by region notsorted;
c.ref();m.ref();
if last.region then do;
Total_Customer=c.num_items;
Total_Used_Method=m.num_items;
c.clear();m.clear();
output;
end;
drop Customer_ID Method;
run;
... View more