Hello,
I am using a panel dataset and I would like to keep individuals who were observed for at least two waves. I have a unique id for each person which is the same regardless of wave, and a wave ID which is included only if the individual was interviewed i.e. someone interviewed in wave 1 and wave 3 will have a wave_id for wave 1 and wave 3 but not wave 2 or wave 4. I also have another variable, panel_, which indicates the base wave (the first time a person was interviewed) and panel wave (if they were reinterviewed).
I would like to keep all individuals who were observed at least twice, regardless of which waves. I am not sure how to do this with my data.
I am using a panel dataset and I would like to keep individuals who were observed for at least two waves. I have a unique id for each person which is the same regardless of wave, and a wave ID which is included only if the individual was interviewed i.e. someone interviewed in wave 1 and wave 3 will have a wave_id for wave 1 and wave 3 but not wave 2 or wave 4. I also have another variable, panel_, which indicates the base wave (the first time a person was interviewed) and panel wave (if they were reinterviewed).
I would like to keep all individuals who were observed at least twice, regardless of which waves. I am not sure how to do this with my data.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str14 UniqueID byte wave str23 wave_id float panel_ "10504000000002" 1 "10504000000002" 0 "10504000000002" 2 "21504000000002" 1 "10504000000002" 3 "" . "10504000000002" 4 "" . "10504000000022" 1 "10504000000022" 0 "10504000000022" 2 "" . "10504000000022" 3 "" . "10504000000022" 4 "" . "10504000000043" 1 "10504000000043" 0 "10504000000043" 2 "21504000000043" 1 "10504000000043" 3 "31504000000043" 1 "10504000000043" 4 "" . "10504000000064" 1 "10504000000064" 0 "10504000000064" 2 "" . "10504000000064" 3 "" . "10504000000064" 4 "" . "10504000000081" 1 "10504000000081" 0 "10504000000081" 2 "" . "10504000000081" 3 "" . "10504000000081" 4 "" . "10504000000113" 1 "10504000000113" 0 "10504000000113" 2 "21504000000113" 1 "10504000000113" 3 "31504000000113" 1 "10504000000113" 4 "41504000000113" 1 "10504000000132" 1 "10504000000132" 0 "10504000000132" 2 "" . "10504000000132" 3 "" . "10504000000132" 4 "" . "10504000000231" 1 "10504000000231" 0 "10504000000231" 2 "21504000000231" 1 "10504000000231" 3 "" . "10504000000231" 4 "" . "10504000000271" 1 "10504000000271" 0 "10504000000271" 2 "" . "10504000000271" 3 "" . "10504000000271" 4 "" . "10504000000330" 1 "10504000000330" 0 "10504000000330" 2 "" . "10504000000330" 3 "" . "10504000000330" 4 "" . "10504000000392" 1 "10504000000392" 0 "10504000000392" 2 "" . "10504000000392" 3 "" . "10504000000392" 4 "" . "10504000000415" 1 "10504000000415" 0 "10504000000415" 2 "" . "10504000000415" 3 "" . "10504000000415" 4 "" . "10504000000444" 1 "10504000000444" 0 "10504000000444" 2 "21504000000444" 1 "10504000000444" 3 "31504000000444" 1 "10504000000444" 4 "" . "10504000000451" 1 "10504000000451" 0 "10504000000451" 2 "" . "10504000000451" 3 "" . "10504000000451" 4 "" . "10504000000454" 1 "10504000000454" 0 "10504000000454" 2 "" . "10504000000454" 3 "" . "10504000000454" 4 "" . "10504000000482" 1 "10504000000482" 0 "10504000000482" 2 "21504000000482" 1 "10504000000482" 3 "" . "10504000000482" 4 "" . "10504000000493" 1 "10504000000493" 0 "10504000000493" 2 "" . "10504000000493" 3 "" . "10504000000493" 4 "" . "10504000000498" 1 "10504000000498" 0 "10504000000498" 2 "" . "10504000000498" 3 "" . "10504000000498" 4 "" . "10504000000526" 1 "10504000000526" 0 "10504000000526" 2 "" . "10504000000526" 3 "" . "10504000000526" 4 "" . "10504000000533" 1 "10504000000533" 0 "10504000000533" 2 "" . "10504000000533" 3 "" . "10504000000533" 4 "" . "10504000000535" 1 "10504000000535" 0 "10504000000535" 2 "21504000000535" 1 "10504000000535" 3 "31504000000535" 1 "10504000000535" 4 "41504000000535" 1 "10504000000561" 1 "10504000000561" 0 "10504000000561" 2 "" . "10504000000561" 3 "" . "10504000000561" 4 "" . "10504000000563" 1 "10504000000563" 0 "10504000000563" 2 "" . "10504000000563" 3 "" . "10504000000563" 4 "" . "10504000000575" 1 "10504000000575" 0 "10504000000575" 2 "" . "10504000000575" 3 "" . "10504000000575" 4 "" . "10504000000611" 1 "10504000000611" 0 "10504000000611" 2 "" . "10504000000611" 3 "" . "10504000000611" 4 "" . end label values wave wave label def wave 1 "Wave 1", modify label def wave 2 "Wave 2", modify label def wave 3 "Wave 3", modify label def wave 4 "Wave 4", modify label values panel_ Lpanel label def Lpanel 0 "Base wave", modify label def Lpanel 1 "Panel wave", modify
Comment