Announcement

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

  • Initial career choice: how to get first non-missing value conditioned on a non-missing value of another variable in panel data

    Dear all,

    I want to create a variable called initial career choice (icc) from a given data (see below). It is panel data, where idi is the individual id, year is the period, age is the individual's age in that particular year, edu_degree is the latest education degree of the individual, and idf is the firm id that the individual works at in that particular year. I include the icc variable that I am trying to calculate.

    icc has 3 conditions to be correctly defined: (1) icc is defined as the first non-missing firm id (idf) after the latest change in the individual's education degree (edu_degree) of the age 30 or less. (2) if the individual does not show any change in their education degree (edu_degree), then icc in that case will be the first non-missing firm id (idf) if and only if the individual's first observation in the data is missing (i.e., the individual entered the sample as unemployed) and also the age is also not more than 30 in this case. (3) I also consider the following case in my sample: an individual who has their latest change in education degree at the age of 30 or less (see (1)), yet their first employment could be after the age of 33.

    Lastly, I exclude individual who have entered the sample with firm id (idf) in their first observation an with no any change in education degree (edu_degree) (see idi==7 in the dataex below).


    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte idi int year byte age int edu_degree byte idf float icc
    1 2012 46 123 . .
    1 2013 47 123 21 .
    1 2014 48 123 25 .
    1 2015 49 123 25 .
    1 2016 50 123 25 .
    1 2017 51 123 25 .
    1 2018 52 123 25 .
    2 2012 16 456 . .
    2 2013 17 456 . .
    2 2014 18 456 . .
    2 2015 19 789 45 1
    2 2016 20 789 45 .
    2 2017 21 789 45 .
    2 2018 22 789 45 .
    3 2012 24 123 78 .
    3 2013 25 456 78 .
    3 2014 26 456 78 .
    3 2015 27 456 54 .
    3 2016 28 789 54 1
    3 2017 29 789 54 .
    4 2012 27 524 . .
    4 2013 28 524 79 .
    4 2014 29 123 . .
    4 2015 30 123 . .
    4 2016 31 123 98 1
    4 2017 32 123 . .
    4 2018 32 689 68 .
    4 2019 33 689 68 .
    5 2012 15 456 . .
    5 2013 16 456 . .
    5 2014 17 456 . .
    5 2015 18 789 . .
    5 2016 19 789 65 1
    6 2012 24 132 . .
    6 2013 25 123 54 .
    6 2014 26 132 . .
    6 2015 27 123 48 .
    6 2016 28 456 . .
    6 2017 29 456 . .
    6 2018 30 798 21 1
    7 2012 22 123 98 .
    7 2013 23 123 98 .
    7 2014 24 123 98 .
    7 2015 25 123 98 .
    7 2016 26 123 98 .
    7 2017 27 123 98 .
    7 2018 28 123 98 .
    7 2019 29 123 98 .
    8 2012 22 456 . .
    8 2013 23 456 . .
    8 2014 24 456 . .
    8 2015 25 456 98 1
    8 2016 26 456 98 .
    8 2017 27 456 98 .
    8 2018 28 456 98 .
    8 2019 29 456 98 .
    9 2012 22 987 98 .
    9 2013 23 987 98 .
    9 2014 24 987 98 .
    9 2015 25 564 . .
    9 2016 26 564 . .
    9 2017 27 564 78 1
    9 2018 28 564 78 .
    9 2019 29 564 88 .
    end




Working...
X