US Genpop

Edited

You can insert this screener into your survey using

s.standard_screener("US", "GenPop")

Or if you want to edit it, just copy and paste the code below:


age = s.numeric_question(
    question="How old are you?",
    min_max=(18, 65),
    recodes={
        "18-24": "18-24",
        "25-34": "25-34",
        "35-44": "35-44",
        "45-54": "45-54",
        "55-64": "55-64",
        "65+": "65+",
    },
)

gender = s.select_question("What is your gender?", ["Male", "Female", "Non-Binary", "Prefer not to say"])

ethnicity = s.select_question(
    "What is your ethnicity?",
    [
        "White",
        "Black",
        "Other",
    ],
)

hispanic = s.select_question("Would you describe yourself as Hispanic?", ["Yes", "No"])

income = s.numeric_question(
    "What is your annual income?",
    min_max=(0, 500000),
    recodes={
        "0-20000": "Less than $20,000",
        "20000-34999": "$20,000 to $34,999",
        "35000-49999": "$35,000 to $49,999",
        "50000-74999": "$50,000 to $74,999",
        "75000-99999": "$75,000 to $99,999",
        "100000-149999": "$100,000 to $149,999",
        "150000+": "$150,000 or more",
    },
)

s.select_question(
    "What is your highest level of education?",
    [
        "Less than high school degree",
        "High school graduate",
        "Some college",
        "Bachelor's degree",
        "Master's degree",
        "Post-graduate degree",
    ],
)

region = s.select_question(
    "Which region of the country do you come from?", options=["Northeast", "Midwest", "South", "West"]
)

s.set_quota(
    name="age",
    quotas=[
        s.quota("18-24", criteria=(18 <= age <= 24), quota=0.12),
        s.quota("25-34", criteria=(25 <= age <= 34), quota=0.18),
        s.quota("35-44", criteria=(35 <= age <= 44), quota=0.17),
        s.quota("45-54", criteria=(45 <= age <= 54), quota=0.16),
        s.quota("55-64", criteria=(55 <= age <= 64), quota=0.17),
        s.quota("65+", criteria=(65 <= age <= 99), quota=0.20),
    ],
)
s.set_quota(
    name="Ethnicity",
    quotas=[
        s.quota("White", criteria=(ethnicity == "White"), quota=0.75),
        s.quota("Black", criteria=(ethnicity == "Black"), quota=0.14),
        s.quota("Other", criteria=(ethnicity == "Other"), quota=0.11),
    ],
)
s.set_quota(
    name="Hispanic",
    quotas=[
        s.quota("Yes", criteria=(hispanic == "Yes"), quota=0.19),
        s.quota("No", criteria=(hispanic == "No"), quota=0.81),
    ],
)
s.set_quota(
    name="Gender",
    quotas=[
        s.quota("Male", criteria=(gender == "Male"), quota=0.49),
        s.quota("Female", criteria=(gender == "Female"), quota=0.51),
    ],
)
s.set_quota(
    name="Income",
    quotas=[
        s.quota("0-24999", criteria=(income < 25000), quota=0.16),
        s.quota("25000-49999", criteria=(income >= 25000) & (income < 50000), quota=0.19),
        s.quota("50000-99999", criteria=(income >= 50000) & (income < 100000), quota=0.28),
        s.quota("100000-149999", criteria=(income >= 100000) & (income < 150000), quota=0.16),
        s.quota("150000-500000", criteria=(income >= 150000), quota=0.21),
    ],
)

s.set_quota(
    name="Region",
    quotas=[
        s.quota("Northeast", criteria=(region == "Northeast"), quota=0.18),
        s.quota("Midwest", criteria=(region == "Midwest"), quota=0.23),
        s.quota("South", criteria=(region == "South"), quota=0.37),
        s.quota("West", criteria=(region == "West"), quota=0.22),
    ],
)

Was this article helpful?

Sorry about that! Care to tell us more?

Thanks for the feedback!

There was an issue submitting your feedback
Please check your connection and try again.