Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Generating a dummy variable for an entire household based on a individual labour market characteristic

    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

  • #2
    Frederick:
    welcome to this forum.
    You may want to try:
    Code:
    g counter=1 if labourmarket==1
    egen wanted=min(counter), by( hhid)
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      (a) no one is unemployed is not the same as (b) someone is employed.

      A family with one employed and one unemployed meets (b) but not (a).

      @Carlo Lazzaro's nice idea of using egen can be tweaked. For example.


      Code:
       
       egen some_employ = max(labourmarket == 1), by( hhid)
      For max() as any and min() as all, see the FAQ https://www.stata.com/support/faqs/d...ble-recording/

      Comment


      • #4
        Carlo Lazzaro Thank you very much for the code work perfectly and I am learning more and more about the magic of egen!

        Also thank you Nick Cox yes I am trying to separate into the 2 groups, a) at least have one household member working, b) no one in the household is in the labour market and income is mainly sourced from remittances or social grants (a condition many households in South Africa fall under). I also tried the code you suggested and it worked very well!

        Thank you for the response and assistance

        Kind regards
        Frederich

        Comment


        • #5
          Good day

          I just have another question

          The same data includes individual and household level data. One of my variables occupations is on an individual level and I want to use this variable to restrict it to one member in the household particularly the member with the highest occupation level). Meaning that if there are a semi-skilled (==1) and a high skilled(==2) in the household then I need a command that can restrict the individual-level data to household level using the highest occupation_level?

          recode occupation (-9/-3=.) (1/3=3 "high skilled") (4/8 0=2 "medium skilled") (9=1 "low skilled"), gen(occupation_level)
          tab occupation_level

          Secondly, those households who do not have any working members I would also like to classify as ==0 (possible restrict it by the household head)

          Kind regards
          Frederich

          Comment

          Working...
          X