Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to generate a variable with only one gender?

    Hello,

    I have a variable which shows whether the respondent works in a male dominated or a female dominated work sector. Now i want to generate two new variables, one which shows only the male respondents and whether they work in a male or female dominated sector and one which shows only the female respondents and whether they work in a male or female dominated sector.

    How can i do that?

    i have tried several code, like the following but none seem to work.

    Gen women_in_sector
    replace women_in_sector = 0 if sector_recode - (sex >1)

    Please help!

  • #2
    I assume that gender==1 is female and gender==2 is male
    gen female_sector=.
    replace female_sector=1 if gender==1 & sector==femaledominated
    replace female_sector=0 if gender==1 & sector==maledominated

    gen male_sector=.
    replace male_sector=1 if gender==2 & sector==maledominated
    replace male_sector=0 if gender==2 & sector==femaledominated

    Is that what you want?

    Comment


    • #3

      This can be shortened to say


      Code:
      gen female_sector = gender == 1 & sector ==
      where the command needs to be completed by a literal string inside " " if sector is a string variable and a numeric value otherwise. And, naturally, change the variable names as needed.

      Advice would be much easier with a data example as requested.

      Comment

      Working...
      X