Rick,
Just extend your code to r*c contingency table . Right ?

proc iml;
/* first arg is row vector of sums of cols; second arg contains sums of rows */
start RandContingency2x2(_c, _r);
c = rowvec(_c);
r = colvec(_r);
tbl = j(nrow(r),ncol(c), 0);
do i=1 to ncol(c);
do j=1 to nrow(r)-1;
call randgen(a, "Hyper", sum(r), r[j], c[i]);
tbl[j,i]= a;
end;
tbl[j,i]= c[i] - tbl[+,i];
end;

return( tbl );
finish;

call randseed(1);
/* marginals from PROC FREQ example */
c = {13 10 20}; /* sum of columns */
r = {15, 8,10}; /* sum of rows */
do i = 1 to 3;
tbl = RandContingency2x2(c, r);
print tbl;
end;
quit;