Announcement

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

  • How to tell Stata "whichever is the highest"?

    Hi Statalist,

    I am trying to create a control variable "Either Parent's Highest Qualification Level". I have two variables Mother's Education (Med) and Father's Education (Fed), for which I have done the recodings. Here is an example for the mother:

    mvdecode w4hiqualmed, mv (-94 -99 -996 -999)
    recode w4hiqualmed (5 6 7 == 1) (3 4 == 2) (2 == 3) (1 == 4) // Qualifications at level 1 (failed school exams), other qualifications (outside standard education), no qualification are treated as one
    label define labelsetqualmed 1 "Did not finish school" 2 "Graduated from school" 3 "Higher education below degree level" 4 "Graduated from college"
    label value w4hiqualmed labelsetqualmed
    tab w4hiqualmed

    How do I now know proceed to tell Stata "take whichever is the highest"?

  • #2
    You're looking for the mathematical concept of -max()-, assuming (based on your example) that education is coded in a strictly increasing order from lowest to highest education level. You would do better to post a data example using -dataex-, as you are asked in the forum FAQ. However, I'll take a reasonable guess, and you can adapt it for your own situation.

    In cases where one parent's education is missing, the value takes on that of the other parent. And if both are missing, returns missing. If this is not what you want, you will need to deal with those cases separately.

    Code:
    gen byte highest_ed = max(Med, Fed)

    Comment

    Working...
    X