Announcement

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

  • How to combine multiple gender variables to one

    Hello everyone,

    I am dealing with a somewhat complicated data that consists information about parents and their children. Therefore, questions about children are repeated 20 times assuming one respondent can have maximum of 20 children. So i have 20 columns for each children questions (e.g. 20 columns of child gender, 20 columns of child marital status, education, distance to parents etc.)

    Since i cannot put 20 variables for gender, marital status, education etc. to my regression, I have to find a var to make these 20 variables into 1 variable. I was wondering if you can help me with this issue? How can i convert these variables into one? What can be the Stata command?

    I am pasting an example of how my data look like. Thanks in advance for your help.
    Best,

    Martin

    mergeid ch_gender_1 ch_gender_2 ch_gender_3 ch_gender_4
    AT-000674-01 Male Male . .
    AT-001215-01
    AT-001492-01 Female Female Female Male
    AT-001492-02 Female Female Female Male



  • #2
    There need to be some rules here for precisely what you want. For example, 3 daughters and 1 son could be one variable that is a count of 4 children or another which is average female of 0.75. There cannot (obviously to me any way) be a reduction to one variable that preserves all the information.

    Comment


    • #3
      I think having '3 daughters and 1 son' kind of variables is going to solve my problem. When i checked the data i can see that most respondents have 0 to 5 children. So i can do the combination you mentioned. One question though: when i try to create only daughters or only sons or 1 son-1 daughter kind of combinations I have to write long codes (as below). Is there an easy code for me to use? Can i create loop? if so how?

      *Creating only girls variable*
      gen onlygirls=.
      replace onlygirls=1 if ch_gender_1==2
      replace onlygirls=1 if ch_gender_2==2
      replace onlygirls=1 if ch_gender_3==2
      replace onlygirls=1 if ch_gender_4==2
      replace onlygirls=1 if ch_gender_5==2
      replace onlygirls=1 if ch_gender_6==2
      replace onlygirls=1 if ch_gender_7==2
      replace onlygirls=1 if ch_gender_8==2
      replace onlygirls=1 if ch_gender_9==2
      replace onlygirls=1 if ch_gender_10==2
      replace onlygirls=1 if ch_gender_11==2
      replace onlygirls=1 if ch_gender_12==2
      replace onlygirls=1 if ch_gender_13==2
      replace onlygirls=1 if ch_gender_14==2
      replace onlygirls=1 if ch_gender_15==2
      replace onlygirls=1 if ch_gender_16==2
      replace onlygirls=1 if ch_gender_17==2
      replace onlygirls=1 if ch_gender_18==2
      replace onlygirls=1 if ch_gender_19==2
      replace onlygirls=1 if ch_gender_20==2

      replace onlygirls=0 if ch_gender_1==1
      replace onlygirls=0 if ch_gender_2==1
      replace onlygirls=0 if ch_gender_3==1
      replace onlygirls=0 if ch_gender_4==1
      replace onlygirls=0 if ch_gender_5==1
      replace onlygirls=0 if ch_gender_6==1
      replace onlygirls=0 if ch_gender_7==1
      replace onlygirls=0 if ch_gender_8==1
      replace onlygirls=0 if ch_gender_9==1
      replace onlygirls=0 if ch_gender_10==1
      replace onlygirls=0 if ch_gender_11==1
      replace onlygirls=0 if ch_gender_12==1
      replace onlygirls=0 if ch_gender_13==1
      replace onlygirls=0 if ch_gender_14==1
      replace onlygirls=0 if ch_gender_15==1
      replace onlygirls=0 if ch_gender_16==1
      replace onlygirls=0 if ch_gender_17==1
      replace onlygirls=0 if ch_gender_18==1
      replace onlygirls=0 if ch_gender_19==1
      replace onlygirls=0 if ch_gender_20==1

      Best regards,
      Martin

      Comment

      Working...
      X