# Stratified sampling for creating test/training sets when there are continous and categorical variables to consider?

Assume a simple clinical study with N=200. Half of the participants are men and half of the participants are women. The hemoglobin of the participants ranges between 80 and 150. There's also several other variables.

I would like to split the data into training and tests for a classification task, in a way that the gender and hemoglobin levels would be balanced in each set.

It is easy to pick 50 male/female to each set, but having simultaneously similar hemoglobin levels is difficult. I guess ideally I should check that the mean and s.d. are on about the same range. How should I go about doing this?

If this has been considered in an article, refs. would be great!

EDIT: to clarify, I want to exclude the possibility of gender or hemoglobin inbalance from affecting the classifier result. It should only depend on the other data I have.

Please let us know what is $Y$ and what is its distribution.