We calculate analytically, for finite-size matrices, joint probability densities of ratios of level spacings in ensembles of random matrices characterized by their associated confining potential. We focus on the ratios of two spacings between three consecutive real eigenvalues, as well as certain generalizations such as the overlapping ratios. The resulting formulas are further analyzed in detail in two specific cases: the beta-Hermite and the beta-Laguerre cases, for which we offer explicit calculations for small N. The analytical results are in excellent agreement with numerical simulations of usual random matrix ensembles, and with the level statistics of a quantum many-body lattice model and zeros of the Riemann zeta function.