Dear Statalisers
My dataset is longitudinal following people from 2008 to 2019. I would like to specifically follow those who were aged between 25 and 34 in 2008 over time as they age, but I'm having trouble with the keep/drop commands.
I have tried things like:
drop if (hgage <35 & year==2008) | (hgage >20 & year==2008)
I can't quite get it to work as whatever I try either includes people outside of this age range or I lose observations from 2009 onwards.
Any help is appreciated
best
Brendan
My dataset is longitudinal following people from 2008 to 2019. I would like to specifically follow those who were aged between 25 and 34 in 2008 over time as they age, but I'm having trouble with the keep/drop commands.
I have tried things like:
drop if (hgage <35 & year==2008) | (hgage >20 & year==2008)
I can't quite get it to work as whatever I try either includes people outside of this age range or I lose observations from 2009 onwards.
Any help is appreciated
best
Brendan
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int year long pid int hgage 2008 100003 55 2009 100003 56 2010 100003 57 2011 100003 58 2012 100003 59 2013 100003 60 2014 100003 61 2015 100003 62 2016 100003 63 2017 100003 64 2018 100003 65 2019 100003 66 2008 100005 23 2009 100005 24 2010 100005 25 2011 100005 26 2012 100005 27 2013 100005 28 2014 100005 29 2015 100005 30 2016 100005 31 2017 100005 32 2018 100005 33 2019 100005 34 2008 100006 21 2009 100006 22 2010 100006 23 2011 100006 24 2012 100006 25 2013 100006 26 2014 100006 27 2015 100006 28 2016 100006 29 2017 100006 30 2018 100006 31 2019 100006 32 2008 100007 16 2009 100007 17 2010 100007 18 2011 100007 19 2012 100007 20 2008 100010 43 2009 100010 44 2010 100010 45 2011 100010 46 2012 100010 47 2013 100010 48 2014 100010 49 2015 100010 50 2016 100010 51 2017 100010 52 2018 100010 53 2019 100010 54 2008 100011 38 2009 100011 39 2008 100014 54 2009 100014 55 2010 100014 56 2011 100014 57 2012 100014 58 2013 100014 59 2014 100014 60 2015 100014 61 2016 100014 62 2018 100014 64 2019 100014 65 2008 100015 51 2009 100015 52 2010 100015 53 2011 100015 54 2012 100015 55 2013 100015 56 2014 100015 57 2015 100015 58 2016 100015 59 2017 100015 60 2018 100015 61 2019 100015 62 2008 100016 26 2009 100016 27 2010 100016 28 2011 100016 29 2012 100016 30 2013 100016 31 2014 100016 32 2015 100016 33 2016 100016 34 2017 100016 35 2018 100016 36 2019 100016 37 2008 100018 47 2009 100018 48 2010 100018 49 2011 100018 50 2012 100018 51 2013 100018 52 2014 100018 53 2015 100018 54 2016 100018 55 2017 100018 56 end label values hgage VHGAGE
Comment