Announcement

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

  • how to create/generate characteristics head of household

    hey there,
    I want to generate the characteristics of the head of a household, the head's gender, age, education, and residence, for my regression, I don't know how to reshape the gender, age, and education because I am new in stata. I m using the survey data for my analysis. please help me.

  • #2
    I don't think anybody can help you without seeing an example data set. The correct code depends on a large number of details about how your data are set up. Please use the -dataex- command to post a representative example from your Stata data set. If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    If you do that, it is very likely you will get a timely and helpful response.

    Comment


    • #3
      can you show a data example? to do so, (1) type -dataex-, (2) copy the lines that correspond to the ones I've highlighted in the attached picture, and (3) paste them in a reply to this thread.
      Click image for larger version

Name:	Skjermbilde 2022-04-13 kl. 20.27.49.png
Views:	1
Size:	26.3 KB
ID:	1659491

      Last edited by Øyvind Snilsberg; 13 Apr 2022, 13:32. Reason: crossed with #2

      Comment


      • #4
        ----------------------- copy starting from the next line -----------------------
        [CODE]
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input long(hhcode psu) byte(province region) int district byte(idc sb1q2 sb1q3 sb1q4 sb1q5 age sb1q62 sb1q63) int sb1q64 byte(sb1q7 sb1q8 sb1q9 sb1q10 sb1q11) float weights int seaq04 byte seaq06
        231100101 2311001 2 1 231 1 1 . 1 1 70 0 0 1949 2 2 98 98 1 143.2484 . .
        231100101 2311001 2 1 231 2 2 1 2 1 70 0 0 1949 2 1 98 98 1 143.2484 . .
        231100101 2311001 2 1 231 3 3 3 1 1 36 0 0 1983 2 4 1 2 1 143.2484 4110 4
        231100101 2311001 2 1 231 4 8 3 2 1 35 0 0 1984 2 3 98 99 1 143.2484 . .
        231100101 2311001 2 1 231 5 4 3 1 1 10 0 0 2009 1 . 3 4 1 143.2484 . .
        231100101 2311001 2 1 231 6 4 3 2 1 8 0 0 2011 1 . 3 4 1 143.2484 . .
        231100102 2311001 2 1 231 1 1 . 1 1 36 0 0 1983 1 . 98 2 1 143.2484 5222 3
        231100102 2311001 2 1 231 2 5 5 2 1 56 0 0 1963 3 . 98 99 1 143.2484 . .
        231100102 2311001 2 1 231 3 6 1 2 1 25 0 0 1994 1 . 98 2 1 143.2484 . .
        231100103 2311001 2 1 231 1 1 . 1 1 65 0 0 1954 2 2 98 98 1 143.2484 7112 3
        231100103 2311001 2 1 231 2 2 1 2 1 60 0 0 1959 2 1 98 98 1 143.2484 . .
        231100103 2311001 2 1 231 3 3 1 1 1 29 0 0 1990 1 . 1 2 1 143.2484 6114 6
        231100103 2311001 2 1 231 4 3 1 2 1 20 0 0 1999 1 . 1 2 1 143.2484 . .
        231100104 2311001 2 1 231 1 1 . 1 1 58 0 0 1961 2 2 98 98 1 143.2484 3132 4
        231100104 2311001 2 1 231 2 2 1 2 1 60 0 0 1959 2 1 98 99 1 143.2484 . .
        231100104 2311001 2 1 231 3 3 3 1 1 25 0 0 1994 1 . 1 2 1 143.2484 7131 3
        231100104 2311001 2 1 231 4 3 3 1 1 23 0 0 1996 1 . 1 2 1 143.2484 6114 6
        231100104 2311001 2 1 231 5 3 3 1 1 22 0 0 1997 1 . 1 2 1 143.2484 . .
        231100104 2311001 2 1 231 6 3 1 1 1 20 0 0 1999 1 . 1 2 1 143.2484 . .
        231100104 2311001 2 1 231 7 3 1 1 1 18 0 0 2001 1 . 1 2 1 143.2484 . .
        231100104 2311001 2 1 231 8 3 1 1 1 15 0 0 2004 1 . 1 2 1 143.2484 . .
        231100104 2311001 2 1 231 9 3 1 1 1 11 0 0 2008 1 . 1 2 1 143.2484 . .
        231100104 2311001 2 1 231 10 3 1 2 1 16 0 0 2003 1 . 1 2 1 143.2484 . .
        231100105 2311001 2 1 231 1 1 . 1 1 52 0 0 1967 2 2 98 99 1 143.2484 5414 4
        231100105 2311001 2 1 231 2 2 1 2 1 50 0 0 1969 2 1 98 98 1 143.2484 . .
        231100105 2311001 2 1 231 3 3 1 2 1 19 0 0 2000 1 . 1 2 1 143.2484 . .
        231100105 2311001 2 1 231 4 3 1 1 1 18 0 0 2001 1 . 1 2 1 143.2484 . .
        231100105 2311001 2 1 231 5 3 1 2 1 16 0 0 2003 1 . 1 2 1 143.2484 . .
        231100105 2311001 2 1 231 6 3 1 2 1 13 0 0 2006 1 . 1 2 1 143.2484 . .
        231100106 2311001 2 1 231 1 1 . 1 1 40 0 0 1979 2 2 98 99 1 143.2484 9313 4
        231100106 2311001 2 1 231 2 2 1 2 1 35 0 0 1984 2 1 98 98 1 143.2484 . .
        231100106 2311001 2 1 231 3 3 1 1 1 18 0 0 2001 1 . 1 2 1 143.2484 . .
        231100106 2311001 2 1 231 4 3 1 1 1 10 0 0 2009 1 . 1 2 1 143.2484 . .
        231100106 2311001 2 1 231 5 3 1 1 1 13 0 0 2006 1 . 1 2 1 143.2484 . .
        231100106 2311001 2 1 231 6 3 1 2 1 15 0 0 2004 1 . 1 2 1 143.2484 . .
        231100107 2311001 2 1 231 1 1 . 1 1 72 0 0 1947 2 2 98 98 1 143.2484 2636 4
        231100107 2311001 2 1 231 2 2 1 2 1 59 0 0 1960 2 1 98 98 1 143.2484 . .
        231100107 2311001 2 1 231 3 3 1 1 1 20 0 0 1999 1 . 1 2 1 143.2484 . .
        231100107 2311001 2 1 231 4 3 3 1 1 37 0 0 1982 2 10 1 2 1 143.2484 5412 4
        231100107 2311001 2 1 231 5 3 3 1 1 30 0 0 1989 2 11 1 2 1 143.2484 5223 4
        231100107 2311001 2 1 231 6 4 3 1 1 7 0 0 2012 1 . 4 10 1 143.2484 . .
        231100107 2311001 2 1 231 7 4 3 1 1 6 0 0 2013 1 . 4 10 1 143.2484 . .
        231100107 2311001 2 1 231 8 4 3 2 1 4 0 0 2015 1 . 4 10 1 143.2484 . .
        231100107 2311001 2 1 231 9 4 3 2 1 3 0 0 2016 1 . 5 11 1 143.2484 . .
        231100107 2311001 2 1 231 10 8 3 2 1 32 0 0 1987 2 4 98 99 1 143.2484 . .
        231100107 2311001 2 1 231 11 8 3 2 1 31 0 0 1988 2 5 98 99 1 143.2484 . .
        231100108 2311001 2 1 231 1 1 . 1 1 53 0 0 1966 2 2 98 98 1 143.2484 2330 4
        231100108 2311001 2 1 231 2 2 1 2 1 47 0 0 1972 2 1 98 98 1 143.2484 . .
        231100108 2311001 2 1 231 3 3 3 1 1 21 0 0 1998 1 . 1 2 1 143.2484 9329 4

        Comment


        • #5
          ----------------------- copy starting from the next line -----------------------
          Code:
          * Example generated by -dataex-. To install: ssc install dataex
          clear
          input long(hhcode psu) byte(province region) int district byte(idc sb1q2 sb1q3 sb1q4 sb1q5 age sb1q62 sb1q63) int sb1q64 byte(sb1q7 sb1q8 sb1q9 sb1q10 sb1q11) float weights int seaq04 byte seaq06
          231100101 2311001 2 1 231  1  1 . 1 1 70 0 0 1949 2  2 98 98 1 143.2484    . .
          231100101 2311001 2 1 231  2  2 1 2 1 70 0 0 1949 2  1 98 98 1 143.2484    . .
          231100101 2311001 2 1 231  3  3 3 1 1 36 0 0 1983 2  4  1  2 1 143.2484 4110 4
          231100101 2311001 2 1 231  4  8 3 2 1 35 0 0 1984 2  3 98 99 1 143.2484    . .
          231100101 2311001 2 1 231  5  4 3 1 1 10 0 0 2009 1  .  3  4 1 143.2484    . .
          231100101 2311001 2 1 231  6  4 3 2 1  8 0 0 2011 1  .  3  4 1 143.2484    . .
          231100102 2311001 2 1 231  1  1 . 1 1 36 0 0 1983 1  . 98  2 1 143.2484 5222 3
          231100102 2311001 2 1 231  2  5 5 2 1 56 0 0 1963 3  . 98 99 1 143.2484    . .
          231100102 2311001 2 1 231  3  6 1 2 1 25 0 0 1994 1  . 98  2 1 143.2484    . .
          231100103 2311001 2 1 231  1  1 . 1 1 65 0 0 1954 2  2 98 98 1 143.2484 7112 3
          231100103 2311001 2 1 231  2  2 1 2 1 60 0 0 1959 2  1 98 98 1 143.2484    . .
          231100103 2311001 2 1 231  3  3 1 1 1 29 0 0 1990 1  .  1  2 1 143.2484 6114 6
          231100103 2311001 2 1 231  4  3 1 2 1 20 0 0 1999 1  .  1  2 1 143.2484    . .
          231100104 2311001 2 1 231  1  1 . 1 1 58 0 0 1961 2  2 98 98 1 143.2484 3132 4
          231100104 2311001 2 1 231  2  2 1 2 1 60 0 0 1959 2  1 98 99 1 143.2484    . .
          231100104 2311001 2 1 231  3  3 3 1 1 25 0 0 1994 1  .  1  2 1 143.2484 7131 3
          231100104 2311001 2 1 231  4  3 3 1 1 23 0 0 1996 1  .  1  2 1 143.2484 6114 6
          231100104 2311001 2 1 231  5  3 3 1 1 22 0 0 1997 1  .  1  2 1 143.2484    . .
          231100104 2311001 2 1 231  6  3 1 1 1 20 0 0 1999 1  .  1  2 1 143.2484    . .
          231100104 2311001 2 1 231  7  3 1 1 1 18 0 0 2001 1  .  1  2 1 143.2484    . .
          231100104 2311001 2 1 231  8  3 1 1 1 15 0 0 2004 1  .  1  2 1 143.2484    . .
          231100104 2311001 2 1 231  9  3 1 1 1 11 0 0 2008 1  .  1  2 1 143.2484    . .
          231100104 2311001 2 1 231 10  3 1 2 1 16 0 0 2003 1  .  1  2 1 143.2484    . .
          231100105 2311001 2 1 231  1  1 . 1 1 52 0 0 1967 2  2 98 99 1 143.2484 5414 4
          231100105 2311001 2 1 231  2  2 1 2 1 50 0 0 1969 2  1 98 98 1 143.2484    . .
          231100105 2311001 2 1 231  3  3 1 2 1 19 0 0 2000 1  .  1  2 1 143.2484    . .
          231100105 2311001 2 1 231  4  3 1 1 1 18 0 0 2001 1  .  1  2 1 143.2484    . .
          231100105 2311001 2 1 231  5  3 1 2 1 16 0 0 2003 1  .  1  2 1 143.2484    . .
          231100105 2311001 2 1 231  6  3 1 2 1 13 0 0 2006 1  .  1  2 1 143.2484    . .
          231100106 2311001 2 1 231  1  1 . 1 1 40 0 0 1979 2  2 98 99 1 143.2484 9313 4
          231100106 2311001 2 1 231  2  2 1 2 1 35 0 0 1984 2  1 98 98 1 143.2484    . .
          231100106 2311001 2 1 231  3  3 1 1 1 18 0 0 2001 1  .  1  2 1 143.2484    . .
          231100106 2311001 2 1 231  4  3 1 1 1 10 0 0 2009 1  .  1  2 1 143.2484    . .
          231100106 2311001 2 1 231  5  3 1 1 1 13 0 0 2006 1  .  1  2 1 143.2484    . .
          231100106 2311001 2 1 231  6  3 1 2 1 15 0 0 2004 1  .  1  2 1 143.2484    . .
          231100107 2311001 2 1 231  1  1 . 1 1 72 0 0 1947 2  2 98 98 1 143.2484 2636 4
          231100107 2311001 2 1 231  2  2 1 2 1 59 0 0 1960 2  1 98 98 1 143.2484    . .
          231100107 2311001 2 1 231  3  3 1 1 1 20 0 0 1999 1  .  1  2 1 143.2484    . .
          231100107 2311001 2 1 231  4  3 3 1 1 37 0 0 1982 2 10  1  2 1 143.2484 5412 4
          231100107 2311001 2 1 231  5  3 3 1 1 30 0 0 1989 2 11  1  2 1 143.2484 5223 4
          231100107 2311001 2 1 231  6  4 3 1 1  7 0 0 2012 1  .  4 10 1 143.2484    . .
          231100107 2311001 2 1 231  7  4 3 1 1  6 0 0 2013 1  .  4 10 1 143.2484    . .
          231100107 2311001 2 1 231  8  4 3 2 1  4 0 0 2015 1  .  4 10 1 143.2484    . .
          231100107 2311001 2 1 231  9  4 3 2 1  3 0 0 2016 1  .  5 11 1 143.2484    . .
          231100107 2311001 2 1 231 10  8 3 2 1 32 0 0 1987 2  4 98 99 1 143.2484    . .
          231100107 2311001 2 1 231 11  8 3 2 1 31 0 0 1988 2  5 98 99 1 143.2484    . .
          231100108 2311001 2 1 231  1  1 . 1 1 53 0 0 1966 2  2 98 98 1 143.2484 2330 4
          231100108 2311001 2 1 231  2  2 1 2 1 47 0 0 1972 2  1 98 98 1 143.2484    . .
          231100108 2311001 2 1 231  3  3 3 1 1 21 0 0 1998 1  .  1  2 1 143.2484 9329 4
          end
          label values province province
          label def province 2 "punjab", modify
          label values region region
          label def region 1 "rural", modify
          label values district district
          label def district 231 "rawalpindi", modify
          label values sb1q2 sb1q2
          label def sb1q2 1 "head", modify
          label def sb1q2 2 "spouse", modify
          label def sb1q2 3 "son/daughter", modify
          label def sb1q2 4 "grand child", modify
          label def sb1q2 5 "father/mother", modify
          label def sb1q2 6 "brother/sister", modify
          label def sb1q2 8 "son/daughter in law", modify
          label def sb1q2 12 "real uncle/aunt", modify
          label values sb1q3 sb1q3
          label def sb1q3 1 "main economic provider", modify
          label def sb1q3 2 "main provider away for work", modify
          label def sb1q3 3 "family elder", modify
          label def sb1q3 5 "main decision maker", modify
          label values sb1q4 sb1q4
          label def sb1q4 1 "male", modify
          label def sb1q4 2 "female", modify
          label values sb1q5 sb1q5
          label def sb1q5 1 "present", modify
          label values sb1q7 sb1q7
          label def sb1q7 1 "unmarried / never married", modify
          label def sb1q7 2 "currently married", modify
          label def sb1q7 3 "widow / widower", modify
          label def sb1q7 4 "divorced", modify
          label values sb1q11 sb1q11
          label def sb1q11 1 "yes", modify
          label values seaq04 LABB
          label def LABB 2151 "“electrical engineers”", modify
          label def LABB 2330 "“secondary education teachers”", modify
          label def LABB 2636 "“religious professionals”", modify
          label def LABB 3132 "“incinerator and water treatment plant operators”", modify
          label def LABB 3511 "“information and communications technology operations technicians”", modify
          label def LABB 4110 "“general office clerks”", modify
          label def LABB 5222 "“shop supervisors”", modify
          label def LABB 5223 "“shop sales assistants”", modify
          label def LABB 5412 "“police officers”", modify
          label def LABB 5414 "“security guards”", modify
          label def LABB 6114 "“mixed crop growers”", modify
          label def LABB 7112 "“bricklayers and related workers”", modify
          label def LABB 7131 "“painters and related workers”", modify
          label def LABB 9112 "“cleaners and helpers in offices, hotels and other establishments”", modify
          label def LABB 9313 "“building construction labourers”", modify
          label def LABB 9329 "“manufacturing labourers not elsewhere classified”", modify
          label values seaq06 LABD
          label def LABD 3 "self employed non agri", modify
          label def LABD 4 "paid employee", modify
          label def LABD 6 "own cultivator", modify

          Comment


          • #6
            Thanks for getting the -dataex- up. You asked for bringing the head of household's age, sex, education, and residence. I don't see any variable in the data set that is called, or looks like it might be, education. For residence, perhaps you mean the variable province? Assuming that, and disregarding education, the code would look like this:

            Code:
            rename sb1q4 sex
            rename sb1q2 relationship
            
            frame put hhcode age sex province if relationship == "head":sb1q2, into(head_data)
            frlink m:1 hhcode, frame(head_data)
            frget age sex province, from(head_data) prefix(head_)
            Note: You don't have to -rename- those variables if you don't want. Personally, I find it beyond frustrating to work with variables names like sb1q4: it is impossible to remember which is which for any substantial period of time, and code using those variable names is completely incomprehensible. So I always make it a point to rename the variables to something that says what they are. But if you don't want to do that, just omit the -rename- statements and replace sex and relationship with sb1q4 and sb1q2 , respectively, in the later lines of the code.

            This code uses -frames- and therefore requires version 16 or later. If you are not using version the current version of Stata (which is 17 at this time) you are supposed to say so in your posts so that nobody wastes time writing code you can't run and you don't waste time trying to run it! If you are running an earlier version, you can use a tempfile instead of a frame. If you need guidance doing that, post back.

            Comment


            • #7
              thanks for your response. I'm using stata 14 and I don't know code use frames or not. I'm again posting my data set again please help.

              ----------------------- copy starting from the next line -----------------------
              Code:
              * Example generated by -dataex-. To install: ssc install dataex
              clear
              input long(hhcode psu) byte(province region) int district byte(idc relationship reason_to_becomehead sex residensial_status age) float weights int Nature_of_work byte(employment_status highest_gradecompleted)
              231100101 2311001 2 1 231  1  1 . 1 1 70 143.2484    . . 10
              231100101 2311001 2 1 231  2  2 1 2 1 70 143.2484    . .  .
              231100101 2311001 2 1 231  3  3 3 1 1 36 143.2484 4110 4 10
              231100101 2311001 2 1 231  4  8 3 2 1 35 143.2484    . . 10
              231100101 2311001 2 1 231  5  4 3 1 1 10 143.2484    . .  .
              231100101 2311001 2 1 231  6  4 3 2 1  8 143.2484    . .  .
              231100102 2311001 2 1 231  1  1 . 1 1 36 143.2484 5222 3  8
              231100102 2311001 2 1 231  2  5 5 2 1 56 143.2484    . .  .
              231100102 2311001 2 1 231  3  6 1 2 1 25 143.2484    . .  .
              231100103 2311001 2 1 231  1  1 . 1 1 65 143.2484 7112 3  .
              231100103 2311001 2 1 231  2  2 1 2 1 60 143.2484    . .  .
              231100103 2311001 2 1 231  3  3 1 1 1 29 143.2484 6114 6 10
              231100103 2311001 2 1 231  4  3 1 2 1 20 143.2484    . . 10
              231100104 2311001 2 1 231  1  1 . 1 1 58 143.2484 3132 4 10
              231100104 2311001 2 1 231  2  2 1 2 1 60 143.2484    . .  5
              231100104 2311001 2 1 231  3  3 3 1 1 25 143.2484 7131 3 10
              231100104 2311001 2 1 231  4  3 3 1 1 23 143.2484 6114 6  8
              231100104 2311001 2 1 231  5  3 3 1 1 22 143.2484    . . 10
              231100104 2311001 2 1 231  6  3 1 1 1 20 143.2484    . .  5
              231100104 2311001 2 1 231  7  3 1 1 1 18 143.2484    . .  .
              231100104 2311001 2 1 231  8  3 1 1 1 15 143.2484    . .  .
              231100104 2311001 2 1 231  9  3 1 1 1 11 143.2484    . .  .
              231100104 2311001 2 1 231 10  3 1 2 1 16 143.2484    . .  .
              231100105 2311001 2 1 231  1  1 . 1 1 52 143.2484 5414 4 12
              231100105 2311001 2 1 231  2  2 1 2 1 50 143.2484    . .  .
              231100105 2311001 2 1 231  3  3 1 2 1 19 143.2484    . .  .
              231100105 2311001 2 1 231  4  3 1 1 1 18 143.2484    . .  .
              231100105 2311001 2 1 231  5  3 1 2 1 16 143.2484    . .  .
              231100105 2311001 2 1 231  6  3 1 2 1 13 143.2484    . .  .
              231100106 2311001 2 1 231  1  1 . 1 1 40 143.2484 9313 4  8
              231100106 2311001 2 1 231  2  2 1 2 1 35 143.2484    . .  5
              231100106 2311001 2 1 231  3  3 1 1 1 18 143.2484    . .  8
              231100106 2311001 2 1 231  4  3 1 1 1 10 143.2484    . .  .
              231100106 2311001 2 1 231  5  3 1 1 1 13 143.2484    . .  .
              231100106 2311001 2 1 231  6  3 1 2 1 15 143.2484    . .  .
              231100107 2311001 2 1 231  1  1 . 1 1 72 143.2484 2636 4 10
              231100107 2311001 2 1 231  2  2 1 2 1 59 143.2484    . .  .
              231100107 2311001 2 1 231  3  3 1 1 1 20 143.2484    . . 12
              231100107 2311001 2 1 231  4  3 3 1 1 37 143.2484 5412 4 13
              231100107 2311001 2 1 231  5  3 3 1 1 30 143.2484 5223 4 13
              231100107 2311001 2 1 231  6  4 3 1 1  7 143.2484    . .  .
              231100107 2311001 2 1 231  7  4 3 1 1  6 143.2484    . .  .
              231100107 2311001 2 1 231  8  4 3 2 1  4 143.2484    . .  .
              231100107 2311001 2 1 231  9  4 3 2 1  3 143.2484    . .  .
              231100107 2311001 2 1 231 10  8 3 2 1 32 143.2484    . . 14
              231100107 2311001 2 1 231 11  8 3 2 1 31 143.2484    . . 13
              231100108 2311001 2 1 231  1  1 . 1 1 53 143.2484 2330 4 16
              231100108 2311001 2 1 231  2  2 1 2 1 47 143.2484    . .  8
              231100108 2311001 2 1 231  3  3 3 1 1 21 143.2484 9329 4 16
              231100108 2311001 2 1 231  4  3 1 1 1 17 143.2484    . .  .
              231100108 2311001 2 1 231  5  3 1 2 1 15 143.2484    . .  .
              231100108 2311001 2 1 231  6 12 5 2 1 73 143.2484    . .  .
              231100109 2311001 2 1 231  1  1 . 2 1 38 143.2484 5414 4 10
              231100109 2311001 2 1 231  2  3 2 1 1 15 143.2484    . .  .
              231100109 2311001 2 1 231  3  3 2 1 1 14 143.2484    . .  .
              231100110 2311001 2 1 231  1  1 . 1 1 40 143.2484 9112 4 12
              231100110 2311001 2 1 231  2  2 1 2 1 38 143.2484    . .  5
              231100110 2311001 2 1 231  3  3 1 1 1 13 143.2484    . .  .
              231100110 2311001 2 1 231  4  3 1 1 1 10 143.2484    . .  .
              231100110 2311001 2 1 231  5  3 1 1 1  8 143.2484    . .  .
              231100110 2311001 2 1 231  6  3 1 2 1  4 143.2484    . .  .
              231100111 2311001 2 1 231  1  1 . 2 1 65 143.2484    . .  .
              231100111 2311001 2 1 231  2  3 3 1 1 28 143.2484 5414 4 10
              231100111 2311001 2 1 231  3  3 3 1 1 35 143.2484 3511 4 13
              231100111 2311001 2 1 231  4  3 1 2 1 30 143.2484    . . 10
              231100111 2311001 2 1 231  5  3 3 1 1 25 143.2484 5223 4  8
              231100112 2311001 2 1 231  1  1 . 1 1 70 143.2484    . . 10
              231100112 2311001 2 1 231  2  2 1 2 1 65 143.2484    . .  .
              231100112 2311001 2 1 231  3  3 3 1 1 40 143.2484 4110 4 12
              231100112 2311001 2 1 231  4  8 3 2 1 38 143.2484    . .  8
              231100112 2311001 2 1 231  5  4 3 2 1 12 143.2484    . .  .
              231100112 2311001 2 1 231  6  4 3 2 1 10 143.2484    . .  .
              231100112 2311001 2 1 231  7  4 3 2 1  8 143.2484    . .  .
              231100112 2311001 2 1 231  8  4 3 1 1  6 143.2484    . .  .
              231100112 2311001 2 1 231  9  4 3 1 1  4 143.2484    . .  .
              231100113 2311001 2 1 231  1  1 . 1 1 70 143.2484    . . 10
              231100113 2311001 2 1 231  2  2 1 2 1 65 143.2484    . .  .
              231100113 2311001 2 1 231  3  3 1 1 1 32 143.2484    . .  5
              231100113 2311001 2 1 231  4  3 1 1 1 30 143.2484 6114 6 10
              231100113 2311001 2 1 231  5  3 1 2 1 40 143.2484    . . 12
              231100113 2311001 2 1 231  6  4 1 1 1 12 143.2484    . .  .
              231100113 2311001 2 1 231  7  3 1 2 1 18 143.2484    . .  .
              231100114 2311001 2 1 231  1  1 . 1 1 76 143.2484    . . 10
              231100114 2311001 2 1 231  2  2 1 2 1 64 143.2484    . .  .
              231100114 2311001 2 1 231  3  3 3 1 1 40 143.2484 4110 4 16
              231100114 2311001 2 1 231  4  8 3 2 1 35 143.2484    . . 16
              231100114 2311001 2 1 231  5  4 3 1 1  4 143.2484    . .  .
              231100114 2311001 2 1 231  6  4 3 1 1  0 143.2484    . .  .
              231100115 2311001 2 1 231  1  1 . 1 1 65 143.2484    . . 10
              231100115 2311001 2 1 231  2  2 1 2 1 60 143.2484    . .  .
              231100115 2311001 2 1 231  3  3 3 1 1 35 143.2484 4110 4 13
              231100115 2311001 2 1 231  4  8 3 2 1 28 143.2484    . . 13
              231100115 2311001 2 1 231  5  4 3 1 1  4 143.2484    . .  .
              231100115 2311001 2 1 231  6  4 3 1 1  1 143.2484    . .  .
              231100115 2311001 2 1 231  7  3 3 1 1 25 143.2484 2151 4 13
              231100116 2311001 2 1 231  1  1 . 1 1 55 143.2484 4110 4  8
              231100116 2311001 2 1 231  2  2 1 2 1 50 143.2484    . .  .
              231100116 2311001 2 1 231  3  3 1 1 1 19 143.2484    . .  .
              231100116 2311001 2 1 231  4  3 1 2 1 25 143.2484    . . 12
              231100116 2311001 2 1 231  5  3 1 2 1 20 143.2484    . . 13
              end
              label values province province
              label def province 2 "punjab", modify
              label values region region
              label def region 1 "rural", modify
              label values district district
              label def district 231 "rawalpindi", modify
              label values relationship sb1q2
              label def sb1q2 1 "head", modify
              label def sb1q2 2 "spouse", modify
              label def sb1q2 3 "son/daughter", modify
              label def sb1q2 4 "grand child", modify
              label def sb1q2 5 "father/mother", modify
              label def sb1q2 6 "brother/sister", modify
              label def sb1q2 8 "son/daughter in law", modify
              label def sb1q2 12 "real uncle/aunt", modify
              label values reason_to_becomehead sb1q3
              label def sb1q3 1 "main economic provider", modify
              label def sb1q3 2 "main provider away for work", modify
              label def sb1q3 3 "family elder", modify
              label def sb1q3 5 "main decision maker", modify
              label values sex sb1q4
              label def sb1q4 1 "male", modify
              label def sb1q4 2 "female", modify
              label values residensial_status sb1q5
              label def sb1q5 1 "present", modify
              label values Nature_of_work LABB
              label def LABB 2151 "“electrical engineers”", modify
              label def LABB 2330 "“secondary education teachers”", modify
              label def LABB 2636 "“religious professionals”", modify
              label def LABB 3132 "“incinerator and water treatment plant operators”", modify
              label def LABB 3511 "“information and communications technology operations technicians”", modify
              label def LABB 4110 "“general office clerks”", modify
              label def LABB 5222 "“shop supervisors”", modify
              label def LABB 5223 "“shop sales assistants”", modify
              label def LABB 5412 "“police officers”", modify
              label def LABB 5414 "“security guards”", modify
              label def LABB 6114 "“mixed crop growers”", modify
              label def LABB 7112 "“bricklayers and related workers”", modify
              label def LABB 7131 "“painters and related workers”", modify
              label def LABB 9112 "“cleaners and helpers in offices, hotels and other establishments”", modify
              label def LABB 9313 "“building construction labourers”", modify
              label def LABB 9329 "“manufacturing labourers not elsewhere classified”", modify
              label values employment_status LABD
              label def LABD 3 "self employed non agri", modify
              label def LABD 4 "paid employee", modify
              label def LABD 6 "own cultivator", modify
              label values highest_gradecompleted sc1q05
              label def sc1q05 5 "class5", modify
              label def sc1q05 8 "class8", modify
              label def sc1q05 10 "class10/ o-level", modify
              label def sc1q05 12 "fa/f.sc/icom/ics/i.com etc", modify
              label def sc1q05 13 "ba/b.sc/b.com", modify
              label def sc1q05 14 "b.ed/m.ed", modify
              label def sc1q05 16 "ma/msc", modify
              ------------------ copy up to and including the previous line ------------------

              Listed 100 out of 22208 observations
              Use the count() option to list more

              Comment


              • #8
                To do it in version 14:

                Code:
                preserve
                keep if relationship == "head":sb1q2
                keep hhcode age sex highest_gradecompleted province
                rename (age sex highest_gradecompleted province) head_=
                tempfile head_data
                save `head_data'
                
                
                restore
                merge m:1 hhcode using `head_data'
                Please remember in future posts to state which version of Stata you are using when it is not the current version. It saves time all around.

                Comment


                • #9
                  thanks alot clyde schechter

                  Comment

                  Working...
                  X