Randomly selecting data to match age and sex distribution of the study sample


Less is more. Stay pure. Stay poor.
So you have a sample and want to match new observations from a population to these data. Add more information please; do you just want two comparable sets or do you want to explicitly case-control match at the personal level. Also, is it an exact match or 1:n match.

P.S., You likely are not 'randomly' selecting is you are trying to match, since you should have criteria or calipers.