Hey there

I am using cross-sectional for South Africa that that includes household(hhid) and individual level(pid) data

I have some employment data ( adult individual level) that I want to use to generate a dummy variable for the entire household if no one in the household is unemployed? So the value would then be 1 for all the household members if someone in the household is employed and 0 if no one in the household is employed.

My individual employment variable is however categorical (0=unemployed; 1=employed; 2=Not economic active) Yet I still just want to get an individual-level variable that equals 1 if you are part of a household with someone in the labour market and 0= if you are part of a household without any household member in the labour market

Below please find an example of my data (Sorted by hhid)


hhid pid labourmarket
500000 636991 1
500000 640576 0
500001 405734 2
500002 305961 1
500002 731651 2
500002 401746 .
500002 630858 .
500003 769557 1
500003 782520 .
500003 763879 .
500003 746176 2
500003 787751 2
500003 303668 2
500003 703450 0
500004 310664 1
500005 319004 1
500006 795652 0
500006 755010 2
500006 630051 .
500006 716968 1
500006 624989 .
500006 734074 2
500006 401698 0
500007 753507 .
500007 747659 .
500007 316119 0
500007 796156 2
500008 408602 2
500008 735370 0


Kind regards
Frederich