computing an empirical copula



I have a set of two variables for which I want to compute an
empirical copula. I have fitted a gamma distribution to both however
I am stuck on how to get the copula. I am thinking I have to do some
type of 4 nested loops in a way to bracket my data (x and y).

However I don't know if anybody knows of a code or a faster way to do
this.

Thank you
Juan
.