What you have is a sampling problem. They key to solving this problem is to break the data into separate groups of the combinations of the three variables. Then, calculate the product of the marginal probabilities of each group (your values are marginal probabilities). Then, normalize these over all 18 groups.
For instance, the Male-Young-Low group would get a value of 0.5*0.3*0.4 = 0.06. You repeat this for all 18 groups and then normalize to a percentage (that is, divide each value by the sum of all the values). Here is the result:
Gender Age Income Marg Normalized
Male Young Low 0.06 5.5%
Male Young Middle 0.06 5.5%
Male Young High 0.03 2.7%
Male Middle Low 0.08 7.3%
Male Middle Middle 0.08 7.3%
Male Middle High 0.04 3.6%
Male Old Low 0.08 7.3%
Male Old Middle 0.08 7.3%
Male Old High 0.04 3.6%
Female Young Low 0.06 5.5%
Female Young Middle 0.06 5.5%
Female Young High 0.03 2.7%
Female Middle Low 0.08 7.3%
Female Middle Middle 0.08 7.3%
Female Middle High 0.04 3.6%
Female Old Low 0.08 7.3%
Female Old Middle 0.08 7.3%
Female Old High 0.04 3.6%
This then becomes your sample rate for each group. Here is pseudo SQL code for actually doing the sampling:
with SamplingRates (
select 'Male' as gender, 'Young' as Age, 'Low' as income, 0.045 as SamplingRate,
union all . .
)
select t.*
from (select t.*,
row_number() over (partition by gender, age, income order by <random>) as seqnum,
count(*) over (partition by gender, age, income) as NumRecs
from table t
) t join
SampleRates sr
on t.gender = sr.gender and t.age = sr.age and t.income = sr.income and
seqnum <= sr.SamplingRate * NumRecs