Dear Stata users,
I am working with panel data and I have the following problem (I applied -xtset hhidpn wave- already). The person identifier is hhidpn, the time variable is wave. I want to delete all observations on an individual if at some point the variable notret changes from 0 to 1. That is: if a person has value 0 for notret at some wave and has a value 1 for that variable in some later wave, all observations on that person should be dropped. I have added a data example.
Data:
Please let me know if anything remains unclear. Thank you for your time.
I am working with panel data and I have the following problem (I applied -xtset hhidpn wave- already). The person identifier is hhidpn, the time variable is wave. I want to delete all observations on an individual if at some point the variable notret changes from 0 to 1. That is: if a person has value 0 for notret at some wave and has a value 1 for that variable in some later wave, all observations on that person should be dropped. I have added a data example.
Data:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long hhidpn byte wave double rliv75r float notret 10003030 13 .9084619372333215 0 10003030 11 1.2403100775193798 0 10003030 10 1.2583125658008716 0 10003030 12 1.2257500496721638 0 10003030 8 1.2999223951313157 0 10003030 9 1.2836672344337199 0 10004040 8 .9304313196912144 0 10004040 5 .9268937632954369 0 10004040 7 1.0142959256611865 0 10004040 9 .612945088814989 0 10004040 6 1.1669289693593314 0 10013040 5 .6674203682571883 1 10013040 8 .5024493185747934 0 10013040 7 1.0252707978226205 1 10013040 6 .5236155988857939 1 10013040 9 .6172236191094169 0 10038040 5 1.3041714213262328 1 10038040 7 1.0560737064936494 1 10038040 6 1.0831107242339832 1 10050010 6 1.0119888579387186 1 10050010 5 1.1587295549638645 1 10097040 5 1.3348407365143766 1 10097040 7 .6407942486391379 0 10097040 6 .6545194986072425 0 10097040 9 .6172236191094169 0 10097040 8 .6280616482184918 0 10210010 5 1.296183593254723 1 10210010 6 .6324930362116991 0 10299011 11 .723068972371298 1 10299011 6 .6619707520891365 0 10299011 10 .8643629142956142 1 10394010 6 .9974164962508522 1 10394010 5 1.041763053680152 1 10394040 8 .37217252787648575 1 10394040 6 .12900974930362116 1 10394040 5 .132413394756491 0 10394040 7 .18901962940561942 0 10397010 5 1.1161747003715916 1 10397010 6 .7124403544648944 1 10397040 5 1.1737542791936095 1 10397040 7 .5006763072524331 1 10397040 6 .9556859331476323 1 10458030 6 1.2900974930362117 1 10458030 5 1.3180761590803431 1 10458030 7 1.1265216913179743 1 10481010 6 .28497614178595776 1 10481010 5 .1488232933828789 1 10481020 5 .9656079624698871 1 10481020 6 .5021615598885794 1 10533010 6 1.0043231197771587 1 10533010 5 1.0299818266345462 1 10600010 6 .6277019498607243 0 10600010 5 .025749545665863655 0 10611010 6 1.1384874651810584 1 10611010 5 1.0299818266345462 1 10672030 6 .7374062713019768 1 10672030 5 1.5342195704890007 1 10672030 7 1.2539677804295943 1 10769040 13 1.0827132432109106 0 10769040 8 .6499611975656578 1 10769040 11 .6201550387596899 0 10769040 9 .6418336172168599 1 10769040 10 1.0066500526406974 1 10769040 12 1.1031750447049473 0 10818040 10 .6061609605927742 0 10818040 9 .6211439154297456 0 10818040 6 1.1173119777158773 1 10818040 7 .6438390058833232 0 10818040 8 1.1367111873544908 1 10818040 5 .6697941760703268 1 10822010 5 1.5047888208509972 1 10822010 6 1.442348329925017 1 10822040 9 1.225890177629978 0 10822040 5 .6648563740613951 0 10822040 7 .6375020619123549 0 10822040 6 .6516155988857939 0 10822040 8 1.2486759520211304 0 10929040 6 .6324930362116991 1 10929040 5 1.3041714213262328 1 10989020 6 1.0043231197771587 1 10989020 5 .9656079624698871 1 11067030 5 1.3543099387658974 1 11067030 6 1.0817612474437628 1 11256010 6 1.4248807089297888 1 11256010 5 1.473350604490501 1 11256040 9 .1225890177629978 0 11256040 5 .39891382443683704 0 11256040 7 .9562530928685324 0 11256040 6 1.2965877437325903 0 11256040 8 .18730139280316954 0 11377040 5 .6648563740613951 1 11377040 7 .5071479628305933 1 11378020 5 .7724863699759097 1 11378020 6 .9415529247910863 0 11466040 11 .12205790763930299 0 11466040 7 .45772598559410566 0 11466040 12 1.082443870454997 0 11466040 9 .6340741341552438 1 11466040 10 1.2348041632794489 1 11466040 8 .6431469454995983 0 end label values notret yesnol label def yesnol 0 "no", modify label def yesnol 1 "yes", modify
Please let me know if anything remains unclear. Thank you for your time.
Comment