Counting cases within subgroups