Announcement

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

  • Creating a categorical variable that takes the value of the higher education category of parents

    Hello everyone,

    I have a categorical dummy variable specifying the education level of the respondents mother and father separately. I want to create a new dummy which takes the value of 1 if (at least) one of the parents has the requested education level, and also including the case where the second parent has a lower education level. So for primary school, I want the dummy to be one if both parents have it OR if one parent has it while the other has a lower education level. How do I code that in STATA?

    Thanks in advance.

  • #2
    Since you did not share the dataset I have to assume how the dataset is structured and in particular how "having primary school" is coded.
    If education level is coded with a number, then it is quite straightforward. I assume the value for primary education is 1 therefore

    Code:
    gen dummy=0
    replace dummy=1 if education_mother==1 & education_father<=1
    replace dummy=1 if education_mother<=1 & education_father==1
    with the first line you set a dummy=0 so to avoid having missing observations, and the second and third line should be what you acatually want.
    maybe there is a more elegant way to do it but this should do.

    Comment


    • #3
      My guess is that Demetrio Guzzardi makes good guesses. Another approach for (0, 1) arguments is

      Code:
      gen wanted = max(education_mother, education_father)
      Note that wanted will be returned as missing if and only both variables are missing. I stop short of guessing what you want in that circumstance.

      For STATA read Stata (FAQ Advice #18).

      Comment


      • #4
        Thanks! Demetrio Guzzardi solution worked for my purpose. The solution from Nick Cox would have worked if I just needed one "highest" parent education dummy, I think. But in my case, I needed a categorical dummy with 5 levels of education for parents (and within each level the condition written by Demetrio). Sorry I didn't clarify that in my description previously. Wish you both a nice weekend

        Comment


        • #5
          Call me stupid but I am struggling to understand the nuance asserted here. For two variables coded 0 and 1 the maximum is precisely equivalent to the code given by Demetrio Guzzardi

          Your wanting several indicators (you say dummies) would seem to imply repetitions of both #2 and #3 for other variables.

          Comment


          • #6
            Yes Nick Cox you are right, the max command was not clear for me in the beginning.

            Comment

            Working...
            X