OK. Here you go.
data pop;
infile cards truncover;
input Row & $40. @;
do col = '1','2','3','4','5','6','7','8','9';
input count @;
output;
end;
datalines;
Asian 0 0 0 1 4 3 6 4 0
African American 0 1 7 16 8 37 57 44 8
Caucasian 0 1 4 13 6 24 51 38 9
Hispanic 0 0 0 0 0 0 0 0 0
Native American 5 1 12 24 24 82 108 90 12
Middle Eastern 0 1 2 10 15 24 31 27 6
Pacific Islander 0 0 1 0 0 3 0 0 0
;
proc freq data=pop; /* Row and column marginals */
weight count/zero;
tables row / noprint out=f2(drop=percent rename=(count=RowF row=mRow));
tables col / noprint out=f3(drop=percent rename=(count=ColF col=mCol));
run;
data all1;
if 0 then merge pop f2 f3;
low = 0;
x0 = 35; * 35 is the x axis value of margin freq;
if _n_ = 1 then do;
row = ' '; col = ' '; mrow = ' '; mcol = ' ';
count = 0; rowf = 0; colf = 0; output;
count = 358; rowf = 358; colf = 358; output; * 358 is the max count in margin freq;
end;
merge pop f2 f3;
output;
run;
ods graphics on / height=4.9in width=6.2in;
title;
proc sgplot data=all1 noautolegend noborder ;
heatmapparm y=row x=col colorresponse=count /colormodel=(white cx6767bb cxbb67bb cxdd2255);
text y=row x=col text=count/ textattrs=(size=8) strip contributeoffsets=none;
highlow y=mrow low=low high=rowf / x2axis
type=bar barwidth=0.95 nooutline colormodel=(white cx6767bb cxbb67bb cxdd2255) colorresponse=rowf;
text y=mrow x=x0 text=rowf / x2axis textattrs=(size=8) strip contributeoffsets=none;
highlow x=mcol low=low high=colf / y2axis
type=bar barwidth=0.95 nooutline colormodel=(white cx6767bb cxbb67bb cxdd2255) colorresponse=colf;
text x=mcol y=x0 text=colf / y2axis textattrs=(size=8) strip contributeoffsets=none;
xaxis display=(nolabel noticks noline) offsetmax=.3;
yaxis display=(nolabel noticks noline) offsetmin=.3 reverse;
x2axis display=none offsetmin=.75 offsetmax=.03;
y2axis display=none offsetmin=.75 offsetmax=.03;
run;
... View more