Dear all,

I am trying to generate years of education variable. Although I have seen some relevant topics in this forum, I think my case is quite different so I make a new thread.

In my data context, primary school take 5 years, secondary school takes 4 years, high school takes 3 years, College takes 2-3 years (2 years, on average), University normally takes 4 years, Master takes 2 years, and finally PhD takes 3-4 years (3 years, on average). The school starting age is at 6, so an individual completes his/her primary school at the age of 11 (6+5), regardless of repetition and later entry which I assume here. Similarly an individual would complete his/her secondary at the age of 15 (6+5+4), and so on.

My dataset contains 3 variables related to an individual's education as follows:
wb3 - Ever attended school
wb4 - highest level of school attended
wb5 - highest grade completed at that level

I wish to provide a data example using dataex as I usually did when posting, however, since there are a few people never attended school, I attached an excel file of my data to show a whole picture of my data structure.

The followings are simple descriptions of the three variables
Code:
-> tabulation of wb3  

       ever |
   attended |
     school |      Freq.     Percent        Cum.
------------+-----------------------------------
        yes |      9,254       94.17       94.17
         no |        573        5.83      100.00
------------+-----------------------------------
      Total |      9,827      100.00

-> tabulation of wb4  

   highest level of school |
                  attended |      Freq.     Percent        Cum.
---------------------------+-----------------------------------
                 preschool |          8        0.09        0.09
                   primary |      1,459       15.77       15.85
           lower secondary |      3,370       36.42       52.27
           upper secondary |      2,412       26.06       78.33
       professional school |        574        6.20       84.54
college/university & above |      1,431       15.46      100.00
---------------------------+-----------------------------------
                     Total |      9,254      100.00

-> tabulation of wb5  

     highest |
       grade |
completed at |
  that level |      Freq.     Percent        Cum.
-------------+-----------------------------------
           0 |        462        6.38        6.38
           1 |         76        1.05        7.43
           2 |        198        2.73       10.16
           3 |        267        3.69       13.85
           4 |        302        4.17       18.02
           5 |        597        8.24       26.27
           6 |        435        6.01       32.27
           7 |        548        7.57       39.84
           8 |        472        6.52       46.36
           9 |      1,774       24.50       70.86
          10 |        453        6.26       77.12
          11 |        407        5.62       82.74
          12 |      1,249       17.25       99.99
     missing |          1        0.01      100.00
-------------+-----------------------------------
       Total |      7,241      100.00
Any help is highly appreciated.

Thank you.