Systematic study of beta and double beta decay to excited final states