Hello! I'm trying to filter out the households (nohhold) that consistently had the value 3 for "woonvorm" for each year. I'm using this command:

Code:
gen byte2 is_3 = inlist(woonvorm, 3)
by nohhold (is_3), sort: gen byte2 consistent2 = (is_3[1] == is_3[_N])
by nohhold: gen byte2 hhflag2 = (_n == 1)
tab consistent2 if hhflag2
The problem is that is then says there are too many variables specified. I have, however, only 40 variables 6567 observation. Is there something wrong with my code?
​​​​​​
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double(nohhold nomem) float year double woonvorm
 106 2 2011 3
 106 2 2017 3
 106 2 2014 3
 106 2 2010 3
 106 2 2011 3
 106 2 2012 3
 106 2 2015 3
 106 2 2015 3
 106 2 2014 3
 106 2 2013 3
 106 2 2016 3
 106 2 2017 3
 106 2 2012 3
 106 2 2010 3
 106 2 2016 3
 106 2 2013 3
 423 2 2013 3
 423 2 2017 3
 423 2 2013 3
 423 2 2014 3
 423 2 2015 3
 423 2 2010 3
 423 2 2015 3
 423 2 2011 3
 423 2 2012 3
 423 2 2011 3
 423 2 2017 3
 423 2 2012 3
 423 2 2016 3
 423 2 2014 3
 423 2 2016 3
 423 2 2010 3
 425 2 2010 3
 425 2 2011 3
 425 2 2011 3
 425 2 2010 3
 425 2 2014 4
 425 2 2013 4
 425 2 2014 4
 425 2 2012 4
 425 2 2013 4
 425 2 2012 4
 633 2 2012 3
 633 2 2014 3
 633 2 2013 3
 633 2 2017 3
 633 2 2011 3
 633 2 2016 3
 633 2 2016 3
 633 2 2017 3
 633 2 2010 3
 633 2 2013 3
 633 2 2010 3
 633 2 2015 3
 633 2 2015 3
 633 2 2014 3
 633 2 2012 3
 633 2 2011 3
 816 2 2010 3
 816 2 2011 3
 816 2 2010 3
 816 2 2011 3
 844 2 2010 3
 844 2 2011 3
 844 2 2011 3
 844 2 2010 3
 873 2 2014 3
 873 2 2010 3
 873 2 2013 3
 873 2 2013 3
 873 2 2012 3
 873 2 2012 3
 873 2 2011 3
 873 2 2016 3
 873 2 2010 3
 873 2 2014 3
 873 2 2017 3
 873 2 2015 3
 873 2 2011 3
 873 2 2016 3
 873 2 2015 3
 873 2 2017 3
 957 1 2010 3
 957 1 2010 3
1159 2 2016 3
1159 2 2014 3
1159 2 2013 3
1159 2 2017 3
1159 2 2010 3
1159 2 2010 3
1159 2 2011 3
1159 2 2016 3
1159 2 2013 3
1159 2 2015 3
1159 2 2017 3
1159 2 2011 3
1159 2 2012 3
1159 2 2014 3
1159 2 2012 3
1159 2 2015 3
end
label values woonvorm woonvorm
label def woonvorm 3 "is living together with partner, child(ren) living at home", modify
label def woonvorm 4 "is living without a partner, but with child(ren)", modify