Announcement

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

  • Cleaning Panel Data for analysis in Latent Gold

    Dear everyone,

    I have been stuck on this particular issue for a while now, and I have decided to post here to see whether anyone might be able to help me out.

    I am currently using data from 15 (yearly) waves of a panel, however, there was some inflow, so some participants have been added to the study later.
    Currently, my data has been set as panel data using an id variable and a variable for 'wave' was created. The data is currently in long format.
    The panel holds variables related to employment status, type of contract etc. and education.

    I want to follow each participant who entered the labour market for 5 consecutive years (although it is worth mentioning that there is a lot of missingness in the dataset) and adjust for some variables at baseline (the year before they enter the labour market, timepoint 0). Since it is panel data with inflow and participants are aged 16 to 75+, the wave that someone enters the labour market may be different for each individual. I want to have 6 timepoints for each individual: timepoint 0 in which they have not entered the labour market and timepoint 1 being the year they enter the labour market. I want to include individuals who have information of their employment status etc. for at least 3 out of the 5 timepoints available (so from timepoint 1-5). I am not sure how I can go about this, however.

    I just want to clean the data as I will be using Latent Gold for a LCA.
    I am aware of the fact that I could use R, however, I have no experience with R yet, so I figured STATA might be faster.

    Please do let me know your thoughts,
    Best wishes,
    Ciel

  • #2
    How can you tell in the data which year the participant entered the labor market? What do you want to do if there are people who were always in the labor market from the very first wave of the survey onward. If somebody is in the labor market and then drops out, and later returns, does the re-entry count as an entry into the labor market?

    Finally, it will be much easier to give you a helpful response is you provide example data using the -dataex- command. If you are running version 18, 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    When asking for help with code, always show example data. When showing example data, always use -dataex-.

    Comment


    • #3
      Dear Clyde,

      Thank you for the quick reply.
      To answer your questions: People who have paid work after (at least one year of) education and who are aged between 25-30 would be considered as people who enter the labour market for the first time.
      People who were always in the labour market will be excluded, I am specifically interested in first-time entry. If someone enters the labour market twice or more (so they enter and then drop-out to go back to school, for example), the first time they entered the will be considered "entering the labour market", meaning that we will still follow them.

      There is a lot of missing data as can be seen from the example below, however, right now, it is hard to determine how much missingness there is and how I want to handle the missing data, as I am not sure how many participants could be included. Although it is evident it would be a small sample.

      Below is some example data:
      Does this example data help?

      Best wishes,
      Ciel


      800001 1 . . . . .
      800001 2 . . . . .
      800001 3 . . . . .
      800001 4 . . . . .
      800001 5 . . . . .
      800001 6 . . . . .
      800001 7 . . . . .
      800001 8 . . . . .
      800001 9 . . . . .
      800001 10 . . . . .
      800001 11 . . . . .
      800001 12 . . . . .
      800001 13 . . . . .
      800001 14 . . . . .
      800001 15 . . . . .
      800002 1 . . . . .
      800002 2 . . . . .
      800002 3 . . . . .
      800002 4 . . . . .
      800002 5 . . . . .
      800002 6 . . . . .
      800002 7 . . . . .
      800002 8 . . . . .
      800002 9 . . . . .
      800002 10 . . . . .
      800002 11 . . . . .
      800002 12 . . . . .
      800002 13 . . . . .
      800002 14 . . . . .
      800002 15 1 2 3 3 1
      800009 1 . . . . .
      800009 2 . . . . .
      800009 3 . . . . .
      800009 4 . . . . .
      800009 5 . . . . .
      800009 6 . . . . .
      800009 7 0 . . . .
      800009 8 0 . . . .
      800009 9 0 . . . .
      800009 10 0 . . . .
      800009 11 . . . . .
      800009 12 0 . . . .
      800009 13 0 . . . .
      800009 14 0 . . . .
      800009 15 0 . . . .
      800012 1 . . . . .
      800012 2 . . . . .
      800012 3 . . . . .
      800012 4 . . . . .
      800012 5 . . . . .
      800012 6 . . . . .
      800012 7 1 2 3 3 .
      800012 8 1 2 4 3 .
      800012 9 . . . . .
      800012 10 . . . . .
      800012 11 . . . . 1
      800012 12 . . . . 1
      800012 13 . . . . .
      800012 14 . . . . .
      800012 15 . . . . .
      800015 1 . . . . 1
      800015 2 . . . . 1
      800015 3 1 2 1 2 1
      800015 4 1 2 3 2 .
      800015 5 1 2 3 2 1
      800015 6 1 2 3 2 .
      800015 7 1 2 3 2 1
      800015 8 1 2 2 3 1
      800015 9 1 3 2 2 1
      800015 10 0 2 2 3 1
      800015 11 1 2 3 2 1
      800015 12 1 1 2 2 1
      800015 13 1 2 2 2 1
      800015 14 1 2 3 2 1
      800015 15 1 2 3 2 1
      800018 1 . . . . .
      800018 2 . . . . .
      800018 3 . . . . .
      800018 4 . . . . .
      800018 5 . . . . .
      800018 6 . . . . .
      800018 7 . . . . .
      800018 8 . . . . .
      800018 9 . . . . .
      800018 10 . . . . .
      800018 11 . . . . .
      800018 12 . . . . .
      800018 13 . . . . .
      800018 14 . . . . .
      800018 15 . . . . .
      800021 1 . . . . .
      800021 2 . . . . .
      800021 3 . . . . .
      800021 4 . . . . .
      800021 5 . . . . .
      800021 6 . . . . .
      800021 7 0 3 4 3 .
      800021 8 . . . . .
      800021 9 . . . . 3
      800021 10 . . . . .

      Comment


      • #4
        I can probably help you with these clarifications, but I need a usable data example. What you have shown is no the output of -dataex-. Nor is it usable as there is no indication what these variables are. The first, I suppose, is a personal ID and the second, wave number. But there is no clue as to what the subsequent variables are. Please post back with an actual example of your data, and use the -dataex- command so that all of the necesssary metadata will be there. Please re-read my response in #2 about the -dataex- command.

        Comment


        • #5
          My apologies!

          Code:
          * Example generated by -dataex-. For more info, type help dataex
          clear
          input double nomem_encr byte wave double(paidwork educadd paidw pwpast unpaidw lookafloss oblnj ftjobseek interr student carehh primeans flo pension disa volunw curempy monthcj overhours irhours skill support apprec promo uncert pleave) float mh
          800001  1 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800001  2 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800001  3 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800001  4 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800001  5 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800001  6 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800001  7 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800001  8 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800001  9 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800001 10 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800001 11 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800001 12 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800001 13 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800001 14 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800001 15 . . . . . . . . . . . . . . . .    .  . . . . . . . . . 72
          800002  1 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800002  2 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800002  3 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800002  4 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800002  5 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800002  6 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800002  7 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800002  8 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800002  9 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800002 10 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800002 11 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800002 12 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800002 13 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800002 14 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800002 15 1 . 1 0 0 0 0 0 0 0 0 0 0 0 0 0 2017  2 2 3 3 3 3 2 1 . 76
          800009  1 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800009  2 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800009  3 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800009  4 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800009  5 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800009  6 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800009  7 0 . 0 1 0 0 0 0 0 0 1 0 0 0 1 1    .  . . . . . . . . .  .
          800009  8 0 . 0 0 0 0 0 0 0 0 0 0 0 0 1 1    .  . . . . . . . . . 80
          800009  9 0 . 0 1 0 0 0 0 0 0 0 0 0 0 1 0    .  . . . . . . . . . 80
          800009 10 0 . 0 0 0 0 0 0 0 0 1 0 0 0 1 1    .  . . . . . . . . . 88
          800009 11 0 . . . . . . . . . . . . . . .    .  . . . . . . . . . 88
          800009 12 0 . 0 0 0 0 0 0 0 0 0 1 0 0 0 1    .  . . . . . . . . . 92
          800009 13 0 . 0 0 0 0 0 0 0 0 1 0 1 0 1 1    .  . . . . . . . . . 88
          800009 14 0 . 0 0 0 0 0 0 0 0 1 0 0 0 1 1    .  . . . . . . . . . 88
          800009 15 0 . 0 0 0 0 0 0 0 0 0 0 0 1 0 0    .  . . . . . . . . . 88
          800012  1 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800012  2 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800012  3 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800012  4 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800012  5 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800012  6 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800012  7 1 . 1 0 0 0 0 0 0 0 0 0 0 0 0 0 2002 10 2 3 3 3 3 2 2 .  .
          800012  8 1 . 1 0 0 0 0 0 0 0 0 0 0 0 0 0 2002 10 2 3 4 4 3 2 1 . 68
          800012  9 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800012 10 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800012 11 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800012 12 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800012 13 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800012 14 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800012 15 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800015  1 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800015  2 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800015  3 1 . 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1992  4 2 2 1 3 2 4 1 . 96
          800015  4 1 . 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1992  4 2 2 3 3 2 3 2 . 76
          800015  5 1 . 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1992  4 2 2 3 3 1 4 2 . 88
          800015  6 1 . 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1992  4 2 2 3 2 1 4 3 . 56
          800015  7 1 . 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1992  4 2 2 3 2 1 4 3 . 92
          800015  8 1 . 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1992  4 2 3 2 3 2 1 3 . 88
          800015  9 1 . 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1992  4 3 2 2 3 2 4 2 . 92
          800015 10 1 . 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1992  4 2 3 2 3 2 3 1 . 92
          800015 11 1 . 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1992  4 2 2 3 3 3 3 1 . 84
          800015 12 1 . 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1992  4 1 2 2 3 3 3 1 . 92
          800015 13 1 . 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1992  4 2 2 2 3 3 3 1 . 88
          800015 14 1 . 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1992  4 2 2 3 3 3 4 2 . 84
          800015 15 1 . 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1994  4 2 2 3 2 2 4 1 . 84
          800018  1 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800018  2 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800018  3 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800018  4 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800018  5 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800018  6 . . . . . . . . . . . . . . . .    .  . . . . . . . . . 68
          800018  7 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800018  8 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800018  9 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800018 10 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800018 11 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800018 12 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800018 13 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800018 14 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800018 15 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800021  1 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800021  2 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800021  3 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800021  4 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800021  5 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800021  6 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800021  7 1 . 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2012  8 3 3 4 3 3 . 2 2  .
          800021  8 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800021  9 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          800021 10 . . . . . . . . . . . . . . . .    .  . . . . . . . . .  .
          end
          label values paidwork cw22o001
          label def cw22o001 0 "No", modify
          label def cw22o001 1 "Yes", modify
          label values educadd cw22o006
          label values paidw cw22o088
          label def cw22o088 0 "No", modify
          label def cw22o088 1 "Yes", modify
          label values pwpast cw22o089
          label def cw22o089 0 "No", modify
          label def cw22o089 1 "Yes", modify
          label values unpaidw cw22o090
          label def cw22o090 0 "No", modify
          label values lookafloss cw22o091
          label def cw22o091 0 "No", modify
          label values oblnj cw22o092
          label def cw22o092 0 "No", modify
          label values ftjobseek cw22o093
          label def cw22o093 0 "No", modify
          label values interr cw22o094
          label def cw22o094 0 "No", modify
          label values student cw22o095
          label def cw22o095 0 "No", modify
          label values carehh cw22o096
          label def cw22o096 0 "No", modify
          label def cw22o096 1 "Yes", modify
          label values primeans cw22o097
          label def cw22o097 0 "No", modify
          label def cw22o097 1 "Yes", modify
          label values flo cw22o098
          label def cw22o098 0 "No", modify
          label def cw22o098 1 "Yes", modify
          label values pension cw22o099
          label def cw22o099 0 "No", modify
          label def cw22o099 1 "Yes", modify
          label values disa cw22o100
          label def cw22o100 0 "No", modify
          label def cw22o100 1 "Yes", modify
          label values volunw cw22o101
          label def cw22o101 0 "No", modify
          label def cw22o101 1 "Yes", modify
          label values monthcj cw22o135
          label def cw22o135 2 "February", modify
          label def cw22o135 4 "April", modify
          label def cw22o135 8 "August", modify
          label def cw22o135 10 "October", modify
          label values overhours cw22o424
          label def cw22o424 1 "often", modify
          label def cw22o424 2 "sometimes", modify
          label def cw22o424 3 "never", modify
          label values irhours cw22o425
          label def cw22o425 2 "sometimes", modify
          label def cw22o425 3 "never", modify
          label values skill cw22o430
          label def cw22o430 1 "disagree entirely", modify
          label def cw22o430 2 "disagree", modify
          label def cw22o430 3 "agree", modify
          label def cw22o430 4 "agree entirely", modify
          label values support cw22o431
          label def cw22o431 2 "disagree", modify
          label def cw22o431 3 "agree", modify
          label def cw22o431 4 "agree entirely", modify
          label values apprec cw22o432
          label def cw22o432 1 "disagree entirely", modify
          label def cw22o432 2 "disagree", modify
          label def cw22o432 3 "agree", modify
          label values promo cw22o434
          label def cw22o434 1 "disagree entirely", modify
          label def cw22o434 2 "disagree", modify
          label def cw22o434 3 "agree", modify
          label def cw22o434 4 "agree entirely", modify
          label values uncert cw22o435
          label def cw22o435 1 "disagree entirely", modify
          label def cw22o435 2 "disagree", modify
          label def cw22o435 3 "agree", modify
          label values pleave cw22o440
          label def cw22o440 2 "No", modify
          This might be correct!

          Comment


          • #6
            Well, we're on the right track now, but not quite there. I assume that we can tell when somebody is doing paid work because the paidwork variable will be 1. But it is unclear how to identify a year of education. There is a variable called student, and perhaps student = 1 defines a year of education? Or must it be both student = 1 and paidwork = 0 at the same time? I don' see anybody with student = 1 and paidwork = 1, but it seems possible in principle. But what then is the variable educadd? The data gives no clue since it is always missing. Anyway, I need an explanation of how to use which variables to ascertain who is doing paid work and who is still in education.

            Finally, I don't see anything that looks helpful for identify age. There is no variable whose name suggests either age or date of birth.

            Comment


            • #7
              Dear Clyde,

              I have thought about your response for a while, hence my late reply. I have made some adjustments to the data.
              If someone performs paid work, paidw will be paidw==1. I have added a variable workingstudent, workingstudent==1 for these observations. There is indeed a variable student in which student==1 for people who are in education.
              There are a bunch of variables to signify why someone may not be working primeans==1 means someone is living off of private means, flo==1 if someone has taken early retirement or if someone has taken job-related early retirement.
              The main issue is thus identifying that someone has entered the labour market while keeping baseline (the year before they enter the labour market) and following them for 5 consecutive years. The variable year-of-birth holds someone's year of birth. Below is a limited data example.

              Code:
              * Example generated by -dataex-. For more info, type help dataex
              clear
              input double nomem_encr byte wave double(yearofbirth paidw) float workingstudent double student
              800001  1 1961 . 0 .
              800001  2 1961 . 0 .
              800001  3 1961 . 0 .
              800001  4 1961 . 0 .
              800001  5 1961 . 0 .
              800001  6 1961 . 0 .
              800001  7 1961 . 0 .
              800001  8 1961 . 0 .
              800001  9 1961 . 0 .
              800001 10 1961 . 0 .
              800001 11 1961 . 0 .
              800001 12 1961 . 0 .
              800001 13 1961 . 0 .
              800001 14 1961 . 0 .
              800001 15 1961 . 0 .
              800002  1 1976 . 0 .
              800002  2 1976 . 0 .
              800002  3 1976 . 0 .
              800002  4 1976 . 0 .
              800002  5 1976 . 0 .
              800002  6 1976 . 0 .
              800002  7 1976 . 0 .
              800002  8 1976 . 0 .
              800002  9 1976 . 0 .
              800002 10 1976 . 0 .
              800002 11 1976 . 0 .
              800002 12 1976 . 0 .
              800002 13 1976 . 0 .
              800002 14 1976 . 0 .
              800002 15 1976 1 0 0
              800009  1 1955 . 0 .
              800009  2 1955 . 0 .
              800009  3 1955 . 0 .
              800009  4 1955 . 0 .
              800009  5 1955 . 0 .
              800009  6 1955 . 0 .
              800009  7 1955 0 0 0
              800009  8 1955 0 0 0
              800009  9 1955 0 0 0
              800009 10 1955 0 0 0
              800009 11 1955 . 0 .
              800009 12 1955 0 0 0
              800009 13 1955 0 0 0
              800009 14 1955 0 0 0
              800009 15 1955 0 0 0
              800012  1    . . 0 .
              800012  2    . . 0 .
              800012  3    . . 0 .
              800012  4    . . 0 .
              800012  5    . . 0 .
              800012  6    . . 0 .
              800012  7    . 1 0 0
              800012  8    . 1 0 0
              800012  9    . . 0 .
              800012 10    . . 0 .
              800012 11    . . 0 .
              800012 12    . . 0 .
              800012 13    . . 0 .
              800012 14    . . 0 .
              800012 15    . . 0 .
              800015  1 1962 . 0 .
              800015  2 1962 . 0 .
              800015  3 1962 1 0 0
              800015  4 1962 1 0 0
              800015  5 1962 1 0 0
              800015  6 1962 1 0 0
              800015  7 1962 1 0 0
              800015  8 1962 1 0 0
              800015  9 1962 1 0 0
              800015 10 1962 0 0 0
              800015 11 1962 1 0 0
              800015 12 1962 1 0 0
              800015 13 1962 1 0 0
              800015 14 1962 1 0 0
              800015 15 1962 1 0 0
              800018  1    . . 0 .
              800018  2    . . 0 .
              800018  3    . . 0 .
              800018  4    . . 0 .
              800018  5    . . 0 .
              800018  6    . . 0 .
              800018  7    . . 0 .
              800018  8    . . 0 .
              800018  9    . . 0 .
              800018 10    . . 0 .
              800018 11    . . 0 .
              800018 12    . . 0 .
              800018 13    . . 0 .
              800018 14    . . 0 .
              800018 15    . . 0 .
              800021  1    . . 0 .
              800021  2    . . 0 .
              800021  3    . . 0 .
              800021  4    . . 0 .
              800021  5    . . 0 .
              800021  6    . . 0 .
              800021  7    . 0 0 0
              800021  8    . . 0 .
              800021  9    . . 0 .
              800021 10    . . 0 .
              800021 11    . . 0 .
              800021 12    . . 0 .
              800021 13    . . 0 .
              800021 14    . . 0 .
              800021 15    . . 0 .
              800028  1 1950 . 0 .
              800028  2 1950 . 0 .
              800028  3 1950 . 0 .
              800028  4 1950 . 0 .
              800028  5 1950 . 0 .
              800028  6 1950 . 0 .
              800028  7 1950 . 0 .
              800028  8 1950 . 0 .
              800028  9 1950 . 0 .
              800028 10 1950 . 0 .
              800028 11 1950 . 0 .
              800028 12 1950 . 0 .
              800028 13 1950 . 0 .
              800028 14 1950 . 0 .
              800028 15 1950 0 0 0
              800033  1    . 1 0 0
              800033  2    . 0 0 0
              800033  3    . 1 1 1
              800033  4    . 1 1 1
              800033  5    . 1 1 1
              800033  6    . . 0 .
              800033  7    . . 0 .
              800033  8    . 1 1 1
              800033  9    . . 0 .
              800033 10    . . 0 .
              800033 11    . . 0 .
              800033 12    . . 0 .
              800033 13    . . 0 .
              800033 14    . . 0 .
              800033 15    . . 0 .
              800039  1    . . 0 .
              800039  2    . . 0 .
              800039  3    . . 0 .
              800039  4    . . 0 .
              800039  5    . . 0 .
              800039  6    . . 0 .
              800039  7    . . 0 .
              800039  8    . . 0 .
              800039  9    . . 0 .
              800039 10    . . 0 .
              800039 11    . . 0 .
              800039 12    . . 0 .
              800039 13    . . 0 .
              800039 14    . . 0 .
              800039 15    . . 0 .
              800042  1    . 1 0 0
              800042  2    . 1 0 0
              800042  3    . 1 0 0
              800042  4    . 1 0 0
              800042  5    . 1 0 0
              800042  6    . 1 0 0
              800042  7    . 1 0 0
              800042  8    . 1 0 0
              800042  9    . 1 0 0
              800042 10    . 1 0 0
              800042 11    . 1 0 0
              800042 12    . 1 0 0
              800042 13    . . 0 .
              800042 14    . . 0 .
              800042 15    . . 0 .
              800045  1    . . 0 .
              800045  2    . . 0 .
              800045  3    . . 0 .
              800045  4    . . 0 .
              800045  5    . . 0 .
              800045  6    . . 0 .
              800045  7    . . 0 .
              800045  8    . . 0 .
              800045  9    . . 0 .
              800045 10    . . 0 .
              800045 11    . . 0 .
              800045 12    . . 0 .
              800045 13    . . 0 .
              800045 14    . . 0 .
              800045 15    . . 0 .
              800054  1    . . 0 .
              800054  2    . . 0 .
              800054  3    . . 0 .
              800054  4    . . 0 .
              800054  5    . . 0 .
              800054  6    . . 0 .
              800054  7    . 0 0 0
              800054  8    . 0 0 0
              800054  9    . 0 0 0
              800054 10    . 0 0 0
              800054 11    . 0 0 0
              800054 12    . 0 0 0
              800054 13    . . 0 .
              800054 14    . . 0 .
              800054 15    . . 0 .
              800057  1 1975 1 0 0
              800057  2 1975 1 0 0
              800057  3 1975 1 0 0
              800057  4 1975 1 0 0
              800057  5 1975 1 0 0
              800057  6 1975 . 0 .
              800057  7 1975 1 0 0
              800057  8 1975 1 0 0
              800057  9 1975 1 0 0
              800057 10 1975 1 0 0
              800057 11 1975 1 0 0
              800057 12 1975 1 0 0
              800057 13 1975 1 0 0
              800057 14 1975 . 0 .
              800057 15 1975 1 0 0
              800058  1    . . 0 .
              800058  2    . . 0 .
              800058  3    . . 0 .
              800058  4    . . 0 .
              800058  5    . . 0 .
              800058  6    . . 0 .
              800058  7    . . 0 .
              800058  8    . . 0 .
              800058  9    . . 0 .
              800058 10    . . 0 .
              800058 11    . . 0 .
              800058 12    . . 0 .
              800058 13    . 1 0 0
              800058 14    . 0 0 1
              800058 15    . 0 1 1
              800073  1    . . 0 .
              800073  2    . . 0 .
              800073  3    . . 0 .
              800073  4    . . 0 .
              800073  5    . . 0 .
              800073  6    . . 0 .
              800073  7    . . 0 .
              800073  8    . . 0 .
              800073  9    . . 0 .
              800073 10    . . 0 .
              800073 11    . 0 0 0
              800073 12    . 0 0 0
              800073 13    . . 0 .
              800073 14    . . 0 .
              800073 15    . . 0 .
              800076  1    . . 0 .
              800076  2    . 1 0 0
              800076  3    . . 0 .
              800076  4    . . 0 .
              800076  5    . . 0 .
              800076  6    . . 0 .
              800076  7    . . 0 .
              800076  8    . . 0 .
              800076  9    . . 0 .
              800076 10    . . 0 .
              800076 11    . . 0 .
              800076 12    . . 0 .
              800076 13    . . 0 .
              800076 14    . . 0 .
              800076 15    . . 0 .
              800085  1 1977 . 0 .
              800085  2 1977 . 0 .
              800085  3 1977 . 0 .
              800085  4 1977 . 0 .
              800085  5 1977 . 0 .
              800085  6 1977 . 0 .
              800085  7 1977 1 0 0
              800085  8 1977 1 0 0
              800085  9 1977 . 0 .
              800085 10 1977 1 0 0
              800085 11 1977 1 0 0
              800085 12 1977 . 0 .
              800085 13 1977 . 0 .
              800085 14 1977 . 0 .
              800085 15 1977 . 0 .
              800091  1 1983 . 0 .
              800091  2 1983 . 0 .
              800091  3 1983 . 0 .
              800091  4 1983 . 0 .
              800091  5 1983 . 0 .
              800091  6 1983 . 0 .
              800091  7 1983 . 0 .
              800091  8 1983 . 0 .
              800091  9 1983 . 0 .
              800091 10 1983 . 0 .
              800091 11 1983 . 0 .
              800091 12 1983 . 0 .
              800091 13 1983 . 0 .
              800091 14 1983 . 0 .
              800091 15 1983 . 0 .
              800100  1 1990 . 0 .
              800100  2 1990 . 0 .
              800100  3 1990 . 0 .
              800100  4 1990 . 0 .
              800100  5 1990 . 0 .
              800100  6 1990 . 0 .
              800100  7 1990 0 0 1
              800100  8 1990 1 1 1
              800100  9 1990 1 0 0
              800100 10 1990 0 0 0
              800100 11 1990 0 0 1
              800100 12 1990 0 0 0
              800100 13 1990 1 0 0
              800100 14 1990 1 0 0
              800100 15 1990 1 1 1
              800106  1 2008 . 0 .
              800106  2 2008 . 0 .
              800106  3 2008 . 0 .
              800106  4 2008 . 0 .
              800106  5 2008 . 0 .
              800106  6 2008 . 0 .
              800106  7 2008 . 0 .
              800106  8 2008 . 0 .
              800106  9 2008 . 0 .
              800106 10 2008 . 0 .
              800106 11 2008 . 0 .
              800106 12 2008 . 0 .
              800106 13 2008 . 0 .
              800106 14 2008 . 0 .
              800106 15 2008 . 0 .
              800109  1    . . 0 .
              800109  2    . . 0 .
              800109  3    . . 0 .
              800109  4    . . 0 .
              800109  5    . 1 0 0
              800109  6    . . 0 .
              800109  7    . . 0 .
              800109  8    . . 0 .
              800109  9    . . 0 .
              800109 10    . . 0 .
              800109 11    . . 0 .
              800109 12    . . 0 .
              800109 13    . . 0 .
              800109 14    . . 0 .
              800109 15    . . 0 .
              800115  1    . . 0 .
              800115  2    . . 0 .
              800115  3    . . 0 .
              800115  4    . . 0 .
              800115  5    . . 0 .
              800115  6    . . 0 .
              800115  7    . . 0 .
              800115  8    . . 0 .
              800115  9    . . 0 .
              800115 10    . . 0 .
              800115 11    . . 0 .
              800115 12    . . 0 .
              800115 13    . . 0 .
              800115 14    . . 0 .
              800115 15    . . 0 .
              800119  1 1950 0 0 0
              800119  2 1950 0 0 0
              800119  3 1950 0 0 0
              800119  4 1950 0 0 0
              800119  5 1950 0 0 0
              800119  6 1950 0 0 0
              800119  7 1950 0 0 0
              800119  8 1950 0 0 0
              800119  9 1950 0 0 0
              800119 10 1950 0 0 0
              800119 11 1950 0 0 0
              800119 12 1950 0 0 0
              800119 13 1950 0 0 0
              800119 14 1950 0 0 0
              800119 15 1950 0 0 0
              800125  1    . 0 0 0
              800125  2    . 1 0 0
              800125  3    . 1 0 0
              800125  4    . . 0 .
              800125  5    . . 0 .
              800125  6    . . 0 .
              800125  7    . . 0 .
              800125  8    . . 0 .
              800125  9    . . 0 .
              800125 10    . . 0 .
              800125 11    . . 0 .
              800125 12    . . 0 .
              800125 13    . . 0 .
              800125 14    . . 0 .
              800125 15    . . 0 .
              800126  1 1966 . 0 .
              800126  2 1966 . 0 .
              800126  3 1966 . 0 .
              800126  4 1966 . 0 .
              800126  5 1966 . 0 .
              800126  6 1966 . 0 .
              800126  7 1966 . 0 .
              800126  8 1966 . 0 .
              800126  9 1966 . 0 .
              800126 10 1966 . 0 .
              800126 11 1966 . 0 .
              800126 12 1966 . 0 .
              800126 13 1966 . 0 .
              800126 14 1966 . 0 .
              800126 15 1966 . 0 .
              800127  1 1983 . 0 .
              800127  2 1983 . 0 .
              800127  3 1983 . 0 .
              800127  4 1983 . 0 .
              800127  5 1983 . 0 .
              800127  6 1983 . 0 .
              800127  7 1983 . 0 .
              800127  8 1983 . 0 .
              800127  9 1983 . 0 .
              800127 10 1983 . 0 .
              800127 11 1983 . 0 .
              800127 12 1983 . 0 .
              800127 13 1983 . 0 .
              800127 14 1983 1 0 0
              800127 15 1983 1 0 0
              800128  1    . . 0 .
              800128  2    . . 0 .
              800128  3    . . 0 .
              800128  4    . . 0 .
              800128  5    . . 0 .
              800128  6    . . 0 .
              800128  7    . . 0 .
              800128  8    . . 0 .
              800128  9    . . 0 .
              800128 10    . . 0 .
              800128 11    . . 0 .
              800128 12    . 1 0 0
              800128 13    . 1 0 0
              800128 14    . 1 0 0
              800128 15    . . 0 .
              800131  1 1954 . 0 .
              800131  2 1954 . 0 .
              800131  3 1954 1 0 0
              800131  4 1954 1 0 0
              800131  5 1954 1 0 0
              800131  6 1954 1 0 0
              800131  7 1954 1 0 0
              800131  8 1954 0 0 0
              800131  9 1954 0 0 0
              800131 10 1954 0 0 0
              800131 11 1954 0 0 0
              800131 12 1954 0 0 0
              800131 13 1954 0 0 0
              800131 14 1954 0 0 0
              800131 15 1954 0 0 0
              800134  1    . . 0 .
              800134  2    . . 0 .
              800134  3    . . 0 .
              800134  4    . . 0 .
              800134  5    . . 0 .
              800134  6    . . 0 .
              800134  7    . . 0 .
              800134  8    . . 0 .
              800134  9    . . 0 .
              800134 10    . . 0 .
              800134 11    . . 0 .
              800134 12    . . 0 .
              800134 13    . . 0 .
              800134 14    . . 0 .
              800134 15    . . 0 .
              800136  1 1962 . 0 .
              800136  2 1962 . 0 .
              800136  3 1962 . 0 .
              800136  4 1962 . 0 .
              800136  5 1962 . 0 .
              800136  6 1962 . 0 .
              800136  7 1962 . 0 .
              800136  8 1962 . 0 .
              800136  9 1962 . 0 .
              800136 10 1962 . 0 .
              800136 11 1962 . 0 .
              800136 12 1962 . 0 .
              800136 13 1962 . 0 .
              800136 14 1962 . 0 .
              800136 15 1962 1 0 0
              800151  1    . . 0 .
              800151  2    . . 0 .
              800151  3    . . 0 .
              800151  4    . . 0 .
              800151  5    . . 0 .
              800151  6    . . 0 .
              800151  7    . . 0 .
              800151  8    . . 0 .
              800151  9    . . 0 .
              800151 10    . . 0 .
              800151 11    . . 0 .
              800151 12    . . 0 .
              800151 13    . . 0 .
              800151 14    . . 0 .
              800151 15    . . 0 .
              800155  1    . 1 0 0
              800155  2    . . 0 .
              800155  3    . . 0 .
              800155  4    . . 0 .
              800155  5    . . 0 .
              800155  6    . . 0 .
              800155  7    . . 0 .
              800155  8    . . 0 .
              800155  9    . . 0 .
              800155 10    . . 0 .
              800155 11    . . 0 .
              800155 12    . . 0 .
              800155 13    . . 0 .
              800155 14    . . 0 .
              800155 15    . . 0 .
              800156  1 1974 . 0 .
              800156  2 1974 . 0 .
              800156  3 1974 . 0 .
              800156  4 1974 . 0 .
              800156  5 1974 . 0 .
              end
              label values paidw cw22o088
              label def cw22o088 0 "No", modify
              label def cw22o088 1 "Yes", modify
              label values student cw22o095
              label def cw22o095 0 "No", modify
              label def cw22o095 1 "Yes", modify

              Comment


              • #8
                OK. I still can't properly implement the age criterion because, while I appreciate your providing the year of birth, there is no indication in your posts or the data what the years of the survey were. Just to illustrate the approach, I have assumed that the survey's first wave took place in 1970--you will see where that asumption shows up in the code, and you can change that to the actual year to get correct age assessments.

                I note that in your data, there are no examples that meet all of your criterion for inclusion in your study. In fact, there are none who both were students at some point prior to entering the labor market and then have five consecutive years of paid work.

                Anyway, here is some code that implements your criteria as I understand them:
                Code:
                //    VERIFY THAT ALL WAVES ARE PRESENT (EVEN IF ALL DATA IS MISSING IN THE WAVE)
                //    FOR ALL ID'S
                by nomem_encr (wave), sort: assert wave == _n
                
                // CRITERION 1: ENTRY INTO LABOR MARKET
                by nomem_encr (wave), sort: gen prior_paid_work = sum(paidw == 1)
                by nomem_encr (wave): egen criterion_1 = ///
                    max(prior_paid_work == 1 & prior_paid_work[_n-1] == 0)
                //    AND MARK THE (POSSIBLE) BASELINE YEAR
                by nomem_encr (wave): egen int baseline_wave = ///
                    min(cond(prior_paid_work == 0 & prior_paid_work[_n+1] == 1, wave, .))
                    
                
                //    CRITERION 2: EDUCATION PRECEDING ENTRY INTO LABOR MARKET
                by nomem_encr (wave): egen criterion_2 = max(student == 1 & prior_paid_work == 0)
                
                //    CRITERION 3: FIVE OR MORE CONSECUTIVE YEARS OF PAID WORK
                by nomem_encr: gen byte criterion_3 = prior_paid_work[baseline_wave+5] == 5
                
                //    CRITERION 4: BETWEEN AGES 25 AND 30 IN BASELINE YEAR
                local year_first_wave = 1970 // REPLACE THIS BY THE ACTUAL YEAR OF THE FIRST WAVE
                gen int age = `year_first_wave' + wave - yearofbirth - 1
                by nomem_encr: egen criterion_4 = max(wave == baseline_wave & inrange(age, 25, 30))
                
                //    KEEP ONLY THOSE MEETING ALL FOUR CRITERIAm AND ONLY THE DATA FROM BASELINE
                //    THROUGH 5 YEARS OF CONSECUTIVE EMPLOYMENT
                keep if criterion_1 & criterion_2 & criterion_3 & criterion_4 ///
                    & inrange(wave, baseline_wave, baseline_wave + 5)

                Comment


                • #9
                  Thank you so much for your time, effort and patience! This helped me out a lot!

                  Comment

                  Working...
                  X