I am using panel data from 2008-2019 and I am trying to identify the number of participants who have been in unemployed at any given time as well as the length they have been unemployed for. I have been able to generate the distinct observations relatively simply but I am struggling with the second part of this hurdle ie(linking the distinct observations to the unemployment status since this isn't always a static response and changes over time).
I have tried to variation of the code below based on some of the previous queries on Statalist that tried to identify distinct observation based on a second characteristic but these efforts haven't been successful.
Code:
bysort ws089_ nomem_encr: gen count = _n == 1 by ws089_: replace count = sum(count) by ws089_: replace count = count[_N]
http://www.stata-journal.com/sjpdf.h...iclenum=dm0042
Example code below
I have been able to relatively simply generate a variable which provides me with the number of Distinct observation using the code:
Code:
by nomem_encr, sort: gen nvals = _n == 1
Code:
* Example generated by -dataex-. For more info, type help dataex clear input double nomem_encr int Year double ws089_ float nvals 800009 2008 . 1 800009 2009 . 0 800009 2010 . 0 800015 2008 . 1 800015 2009 . 0 800015 2010 0 0 800018 2008 . 1 800018 2009 . 0 800018 2010 . 0 800033 2008 0 1 800033 2009 0 0 800033 2010 0 0 800042 2008 0 1 800042 2009 0 0 800042 2010 0 0 800054 2008 . 1 800054 2009 . 0 800054 2010 . 0 800057 2008 0 1 800057 2009 0 0 800057 2010 0 0 800076 2008 . 1 800076 2009 0 0 800076 2010 . 0 800085 2008 . 1 800085 2009 . 0 800085 2010 . 0 800100 2008 . 1 800100 2009 . 0 800100 2010 . 0 800119 2008 1 1 800119 2009 1 0 800119 2010 1 0 800125 2008 1 1 800125 2009 0 0 800125 2010 0 0 800131 2008 . 1 800131 2009 . 0 800131 2010 0 0 800134 2008 . 1 800134 2009 . 0 800134 2010 . 0 800155 2008 0 1 800155 2009 . 0 800155 2010 . 0 800158 2008 0 1 800158 2009 . 0 800158 2010 . 0 800161 2008 . 1 800161 2009 . 0 end label values ws089_ cw11d089 label def cw11d089 0 "no", modify label def cw11d089 1 "yes", modify
0 Response to Identifying how many times Distinct Observations occur within another variable.
Post a Comment