proc sort data=sashelp.baseball out=baseball; by league division; run; proc freq data=baseball; tables team/nocum out=base; by league division; run; proc sql; create table d as select league, division, sum(Count) as totalplayers from base group by league, division; quit; proc sql noprint; select totalplayers into :n1 - :n4 from d order by league, division; quit; %put &n1 &n2 &n3 &n4; data base1; merge base d; by league division; count_percent=strip(put(count,best.))||"("||strip(round(percent,0.01))||")"; abbre=substr(league,1,1)||substr(division,1,1); run; proc sort data=base1; by team; run; proc transpose data=base1 out=base2; by team; var count_percent; id abbre; run; data base3; set base2; if missing(NE) then NE="0(0.00)"; if missing(NW) then NW="0(0.00)"; if missing(AE) then AE="0(0.00)"; if missing(AW) then AW="0(0.00)"; run; proc report data=base3 headskip headline nowd center split='*'; column Team gap ("National" NE NW ) ("American" AE AW ); define Team/ "Teams" ; define gap / ' ' style={cellwidth=0.75in}; define NE/ "East*(N=&n3)"; define NW/ "West*(N=&n4)"; define AE/ "East*(N=&n1)" ; define AW/ "West*(N=&n2)" ; run;
... View more