In this post one can find how to generate random 2-way contingency tables. But what would be the most efficient way to control for the presence/absence of association and the st