May be you could try selective use of either ceil() or floor() on each element of the matrix. You could force either the row sums or the column sums to be correct and it is likely the other will be very close. For example: proc iml;
start rowround( x );
s = x;
do i = 1 to nrow(x);
d = x[i, ] - floor(x[i, ]);
s[i, ] = rank(d) > round(ncol(x) - sum(d));
end;
do i = 1 to nrow(x); do j = 1 to ncol(x);
if s[i,j] then s[i,j] = ceil(x[i,j]);
else s[i,j] = floor(x[i,j]);
end; end;
return(s);
finish;
side = {34, 23, 21, 16, 16, 21, 12};
bottom = {60 52 31};
total = sum(side); /* = sum(bottom); */
table = side*bottom/side[+]; /* null model of independence */
print table;
table = rowround(table);
print table ,, bottom, (table[+,]), side (table[,+]);
quit;
... View more