Announcement

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

  • Age at first birth

    Dear Statalist,

    I am trying to figure out 'Age at first birth for man' through their date of birth and their first child's date of birth. However, when I subtract man's date of birth from their first child's date of birth I get no observations.

    I have attached a sample data set with this post where var11 on the data set refers to gender; 1 is Male and 2 is female



    Below is the code that I used:



    Code:
    *Age at First Birth
    
     tab p150104, m //year of birth.
     
     *****Create Man's birth year
     gen birthyearman=.
     replace birthyearman=p150104 if man==1
     label variable birthyearman"Man's birth year"
     tab birthyearman, m
     tab birthyearman
     
     ***Create first child's birth year
     gen birthyearfirst=dobylunar if child==1
     tab birthyearfirst, m
     tab birthyearfirst
    
    *Now
     gen ageatfirstbirth=birthyearfirst-birthyearman
     label variable ageatfirstbirth"Age at first birth"
     tab ageatfirstbirth, m
     tab ageatfirstbirth
    Thank you for your help.

    Best,
    Bibek Sharma
    Attached Files
    Last edited by Bibek Sharma; 23 Mar 2016, 03:40.

  • #2
    We prefer that you give self-contained data and code examples. dataex from SSC was written for this purpose. See http://www.statalist.org/forums/help#stata -- although I note that you've been given this advice at least twice before in previous threads by Stephen Jenkins and Clyde Schechter.
    Last edited by Nick Cox; 23 Mar 2016, 03:48.

    Comment


    • #3
      Attempting to run your sample code on your sample data fails because the sample data does not include p150104. I concur with Nick (and Stephen's and Clyde's) recommendation that you install and use dataex to post your sample data.

      Comment


      • #4
        Hi,

        Apologies. This is my first time using dataex and I am not quite sure if I have done it properly but eager to learn from my mistakes.

        Code:


        Code:
        *****Create Man's birth year
         gen birthyearman=.
         replace birthyearman=yearofbirth if man==1
         tab birthyearman, m
         tab birthyearman
         
         ***Create first child's birth year
         gen birthyearfirst=dobylunar if child==1
         tab birthyearfirst, m
         tab birthyearfirst
         
         gen ageatfirstbirth=birthyearfirst-birthyearman
        
         label variable ageatfirstbirth"Age at first birth"
         tab ageatfirstbirth, m
         tab ageatfirstbirth

        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input int pid byte gender int dobylunar byte dobmlunar int dobysolar byte(dobmsolar age man woman child var11) int yearofbirth
          101 2 1941 12 1942  2 71 . 1 . 2 1941
          101 2 1941 12 1942  2 71 . 1 . 2 1941
          101 2 1941 12 1942  2 71 . 1 . 2 1941
          101 2 1941 12 1942  2 71 . 1 . 2 1941
          102 1 1968  3 1968  3 44 1 . . 1 1968
          102 1 1968  3 1968  3 44 1 . . 1 1968
          102 1 1968  3 1968  3 44 1 . . 1 1968
          102 1 1968  3 1968  3 44 1 . . 1 1968
          102 1 1968  3 1968  3 44 1 . . 1 1968
          201 1 1951  8 1951  9 61 1 . . 1 1951
          201 1 1951  8 1951  9 61 1 . . 1 1951
          201 1 1951  8 1951  9 61 1 . . 1 1951
          201 1 1951  8 1951  9 61 1 . . 1 1951
          202 2 1954  3 1954  4 58 . 1 . 2 1954
          203 .    .  .    .  .  . . . . .    .
          203 .    .  .    .  .  . . . . .    .
          203 .    .  .    .  .  . . . . .    .
          203 .    .  .    .  .  . . . . .    .
          203 .    .  .    .  .  . . . . .    .
          301 .    .  .    .  .  . . . . .    .
          301 .    .  .    .  .  . . . . .    .
          301 .    .  .    .  .  . . . . .    .
          301 .    .  .    .  .  . . . . .    .
          301 .    .  .    .  .  . . . . .    .
          401 1 1970  1 1970  1 42 1 . . 1 1970
          402 2 1969 11 1969 12 43 . 1 . 2 1969
          402 2 1969 11 1969 12 43 . 1 . 2 1969
          402 2 1969 11 1969 12 43 . 1 . 2 1969
          403 1 1999  1 1999  1 13 . . 1 .    .
          501 .    .  .    .  .  . . . . .    .
          501 .    .  .    .  .  . . . . .    .
          501 .    .  .    .  .  . . . . .    .
          501 .    .  .    .  .  . . . . .    .
          501 .    .  .    .  .  . . . . .    .
          601 .    .  .    .  .  . . . . .    .
          601 .    .  .    .  .  . . . . .    .
          602 2 1935  2 1935  3 77 . 1 . 2 1935
          602 2 1935  2 1935  3 77 . 1 . 2 1935
          602 2 1935  2 1935  3 77 . 1 . 2 1935
          602 2 1935  2 1935  3 77 . 1 . 2 1935
          602 2 1935  2 1935  3 77 . 1 . 2 1935
          602 2 1935  2 1935  3 77 . 1 . 2 1935
          602 2 1935  2 1935  3 77 . 1 . 2 1935
          602 2 1935  2 1935  3 77 . 1 . 2 1935
          602 2 1935  2 1935  3 77 . 1 . 2 1935
          602 2 1935  2 1935  3 77 . 1 . 2 1935
          602 2 1935  2 1935  3 77 . 1 . 2 1935
          603 .    .  .    .  .  . . . . .    .
          603 .    .  .    .  .  . . . . .    .
          603 .    .  .    .  .  . . . . .    .
          603 .    .  .    .  .  . . . . .    .
          604 .    .  .    .  .  . . . . .    .
          701 .    .  .    .  .  . . . . .    .
          801 .    .  .    .  .  . . . . .    .
          801 .    .  .    .  .  . . . . .    .
          801 .    .  .    .  .  . . . . .    .
          801 .    .  .    .  .  . . . . .    .
          801 .    .  .    .  .  . . . . .    .
          801 .    .  .    .  .  . . . . .    .
          801 .    .  .    .  .  . . . . .    .
          801 .    .  .    .  .  . . . . .    .
          801 .    .  .    .  .  . . . . .    .
          902 2 1970  1 1970  2 42 . 1 . 2 1970
          903 2 1972  8 1972  9 40 . 1 . 2 1972
          903 2 1972  8 1972  9 40 . 1 . 2 1972
          903 2 1972  8 1972  9 40 . 1 . 2 1972
          903 2 1972  8 1972  9 40 . 1 . 2 1972
          903 2 1972  8 1972  9 40 . 1 . 2 1972
          903 2 1972  8 1972  9 40 . 1 . 2 1972
          903 2 1972  8 1972  9 40 . 1 . 2 1972
         1001 2 1954  1 1954  2 58 . 1 . 2 1954
         1001 2 1954  1 1954  2 58 . 1 . 2 1954
         1101 1 1957  1 1957  2 55 1 . . 1 1957
         1101 1 1957  1 1957  2 55 1 . . 1 1957
         1101 1 1957  1 1957  2 55 1 . . 1 1957
         1101 1 1957  1 1957  2 55 1 . . 1 1957
         1101 1 1957  1 1957  2 55 1 . . 1 1957
         1101 1 1957  1 1957  2 55 1 . . 1 1957
         1101 1 1957  1 1957  2 55 1 . . 1 1957
         1101 1 1957  1 1957  2 55 1 . . 1 1957
         1101 1 1957  1 1957  2 55 1 . . 1 1957
         1102 2 1949  2 1949  3 63 . 1 . 2 1949
         1102 2 1949  2 1949  3 63 . 1 . 2 1949
         1102 2 1949  2 1949  3 63 . 1 . 2 1949
         1102 2 1949  2 1949  3 63 . 1 . 2 1949
         1102 2 1949  2 1949  3 63 . 1 . 2 1949
         1102 2 1949  2 1949  3 63 . 1 . 2 1949
         1102 2 1949  2 1949  3 63 . 1 . 2 1949
         1102 2 1949  2 1949  3 63 . 1 . 2 1949
         1102 2 1949  2 1949  3 63 . 1 . 2 1949
         1102 2 1949  2 1949  3 63 . 1 . 2 1949
         1102 2 1949  2 1949  3 63 . 1 . 2 1949
         1102 2 1949  2 1949  3 63 . 1 . 2 1949
         1102 2 1949  2 1949  3 63 . 1 . 2 1949
         1102 2 1949  2 1949  3 63 . 1 . 2 1949
         1102 2 1949  2 1949  3 63 . 1 . 2 1949
         1103 1 1987  6 1987  6 25 . . 1 1 1987
         1201 .    .  .    .  .  . . . . .    .
         1201 .    .  .    .  .  . . . . .    .
         1201 .    .  .    .  .  . . . . .    .
         1201 .    .  .    .  .  . . . . .    .
         1201 .    .  .    .  .  . . . . .    .
         1201 .    .  .    .  .  . . . . .    .
         1201 .    .  .    .  .  . . . . .    .
         1201 .    .  .    .  .  . . . . .    .
         1201 .    .  .    .  .  . . . . .    .
         1202 .    .  .    .  .  . . . . .    .
         1203 .    .  .    .  .  . . . . .    .
         1203 .    .  .    .  .  . . . . .    .
         1203 .    .  .    .  .  . . . . .    .
         1203 .    .  .    .  .  . . . . .    .
         1203 .    .  .    .  .  . . . . .    .
         1301 1 1942 12 1942 12 70 1 . . 1 1942
         1301 1 1942 12 1942 12 70 1 . . 1 1942
         1301 1 1942 12 1942 12 70 1 . . 1 1942
         1301 1 1942 12 1942 12 70 1 . . 1 1942
         1302 .    .  .    .  .  . . . . .    .
         1302 .    .  .    .  .  . . . . .    .
         1302 .    .  .    .  .  . . . . .    .
         1302 .    .  .    .  .  . . . . .    .
         1303 .    .  .    .  .  . . . . .    .
         1304 .    .  .    .  .  . . . . .    .
         1401 1 1935 11 1935 12 77 1 . . 1 1935
         1401 1 1935 11 1935 12 77 1 . . 1 1935
         1401 1 1935 11 1935 12 77 1 . . 1 1935
         1401 1 1935 11 1935 12 77 1 . . 1 1935
         1402 2 1937  2 1937  4 75 . 1 . 2 1937
         1402 2 1937  2 1937  4 75 . 1 . 2 1937
         1402 2 1937  2 1937  4 75 . 1 . 2 1937
         1402 2 1937  2 1937  4 75 . 1 . 2 1937
         1403 1 1972  2 1972  3 40 1 . . 1 1972
         1404 .    .  .    .  .  . . . . .    .
         1404 .    .  .    .  .  . . . . .    .
         1404 .    .  .    .  .  . . . . .    .
         1404 .    .  .    .  .  . . . . .    .
         1404 .    .  .    .  .  . . . . .    .
         1501 .    .  .    .  .  . . . . .    .
         1501 .    .  .    .  .  . . . . .    .
         1501 .    .  .    .  .  . . . . .    .
         1501 .    .  .    .  .  . . . . .    .
         1501 .    .  .    .  .  . . . . .    .
         1501 .    .  .    .  .  . . . . .    .
         1502 2 1955  3 1955  3 57 . 1 . 2 1955
         1502 2 1955  3 1955  3 57 . 1 . 2 1955
         1502 2 1955  3 1955  3 57 . 1 . 2 1955
         1503 1 1979  9 1979  9 33 . . 1 .    .
         1503 1 1979  9 1979  9 33 . . 1 .    .
         1503 1 1979  9 1979  9 33 . . 1 .    .
         1503 1 1979  9 1979  9 33 . . 1 .    .
         1503 1 1979  9 1979  9 33 . . 1 .    .
         1503 1 1979  9 1979  9 33 . . 1 .    .
         1503 1 1979  9 1979  9 33 . . 1 .    .
         1601 2 1948 10 1948 11 64 . 1 . 2 1948
         1601 2 1948 10 1948 11 64 . 1 . 2 1948
         1601 2 1948 10 1948 11 64 . 1 . 2 1948
         1601 2 1948 10 1948 11 64 . 1 . 2 1948
         1601 2 1948 10 1948 11 64 . 1 . 2 1948
         1601 2 1948 10 1948 11 64 . 1 . 2 1948
         1601 2 1948 10 1948 11 64 . 1 . 2 1948
         1601 2 1948 10 1948 11 64 . 1 . 2 1948
         1601 2 1948 10 1948 11 64 . 1 . 2 1948
         1601 2 1948 10 1948 11 64 . 1 . 2 1948
         1601 2 1948 10 1948 11 64 . 1 . 2 1948
         1601 2 1948 10 1948 11 64 . 1 . 2 1948
         1601 2 1948 10 1948 11 64 . 1 . 2 1948

        Thank you.

        Best,
        Bibek
        Last edited by Bibek Sharma; 23 Mar 2016, 12:05.

        Comment


        • #5
          That helps, but many crucial details are not explained:

          Why the duplicates?

          What defines a family (household, whatever)? Nothing whatsoever in your code seems to respect any kind of grouping by family.

          Most crucially, subtracting a man's age from his first child's age won't work when they are values in different observations.

          There are easy solutions to this, but they depend on having a family identifier. If there is one here, it is not explained so far as I can see.

          Comment


          • #6
            Hi,

            Thank you for your reply.

            The duplicates are there because an individual's employment status is observed at every time period when he was employed and unemployed.

            There is hhid in the dataset. Below is a dataex with more variables.

            The variables in the data set 'Child' refers to first child and 'Man' refers to the father of the first child but I couldn't figure out how to make a connection in order to create a man's age at first birth.
            Code:
            *Man's birth year
            gen birthyearman=dobylunar if Man==1
             
            *Child's birthyear
            gen birthyearchild=dobylunar if Child==1 
            
            *age
            gen ageatfirstbirth=birthyearchild-birthyearman 
            tab ageatfirstbirth

            Code:
            * Example generated by -dataex-. To install: ssc install dataex
            clear
            input int hhid15 byte hh_num int pid byte(gender relation) int dobylunar byte dobmlunar int dobysolar byte(dobmsolar age woman child) int p150104 str10 empstatus
               1 1  101 2 10 1941 12 1942  2 71 1 . 1941 "employed"  
               1 1  101 2 10 1941 12 1942  2 71 1 . 1941 "employed"  
               1 1  101 2 10 1941 12 1942  2 71 1 . 1941 "employed"  
               1 1  101 2 10 1941 12 1942  2 71 1 . 1941 "unemployed"
               1 1  101 2 10 1941 12 1942  2 71 1 . 1941 "unemployed"
            7258 1  102 1 10 1968  3 1968  3 44 . . 1968 "unemployed"
            7258 1  102 1 10 1968  3 1968  3 44 . . 1968 "unemployed"
            7258 1  102 1 10 1968  3 1968  3 44 . . 1968 "employed"  
            7258 1  102 1 10 1968  3 1968  3 44 . . 1968 "employed"  
            7258 1  102 1 10 1968  3 1968  3 44 . . 1968 "employed"  
            6034 1  201 1 10 1951  8 1951  9 61 . . 1951 "unemployed"
            6034 1  201 1 10 1951  8 1951  9 61 . . 1951 "employed"  
            6034 1  201 1 10 1951  8 1951  9 61 . . 1951 "employed"  
            6034 1  201 1 10 1951  8 1951  9 61 . . 1951 "unemployed"
               2 2  202 2 10 1954  3 1954  4 58 1 . 1954 "employed"  
               4 1  401 1 10 1970  1 1970  1 42 . . 1970 "employed"  
               4 2  402 2 20 1969 11 1969 12 43 1 . 1969 "employed"  
               4 2  402 2 20 1969 11 1969 12 43 1 . 1969 "employed"  
               4 2  402 2 20 1969 11 1969 12 43 1 . 1969 "unemployed"
               4 3  403 1 11 1999  1 1999  1 13 . 1    . ""          
               6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "unemployed"
               6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "unemployed"
               6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "unemployed"
               6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "employed"  
               6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "employed"  
               6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "employed"  
               6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "employed"  
               6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "employed"  
               6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "employed"  
               6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "unemployed"
               6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "unemployed"
               9 4  902 2 10 1970  1 1970  2 42 1 . 1970 "employed"  
            6056 1  903 2 20 1972  8 1972  9 40 1 . 1972 "employed"  
            6056 1  903 2 20 1972  8 1972  9 40 1 . 1972 "unemployed"
            6056 1  903 2 20 1972  8 1972  9 40 1 . 1972 "unemployed"
            6056 1  903 2 20 1972  8 1972  9 40 1 . 1972 "employed"  
            6056 1  903 2 20 1972  8 1972  9 40 1 . 1972 "employed"  
            6056 1  903 2 20 1972  8 1972  9 40 1 . 1972 "employed"  
            6056 1  903 2 20 1972  8 1972  9 40 1 . 1972 "unemployed"
              10 1 1001 2 10 1954  1 1954  2 58 1 . 1954 "unemployed"
              10 1 1001 2 10 1954  1 1954  2 58 1 . 1954 "employed"  
              11 1 1101 1 10 1957  1 1957  2 55 . . 1957 "employed"  
              11 1 1101 1 10 1957  1 1957  2 55 . . 1957 "employed"  
              11 1 1101 1 10 1957  1 1957  2 55 . . 1957 "unemployed"
              11 1 1101 1 10 1957  1 1957  2 55 . . 1957 "employed"  
              11 1 1101 1 10 1957  1 1957  2 55 . . 1957 "unemployed"
              11 1 1101 1 10 1957  1 1957  2 55 . . 1957 "employed"  
              11 1 1101 1 10 1957  1 1957  2 55 . . 1957 "unemployed"
              11 1 1101 1 10 1957  1 1957  2 55 . . 1957 "unemployed"
              11 1 1101 1 10 1957  1 1957  2 55 . . 1957 "employed"  
              11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "unemployed"
              11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "employed"  
              11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "employed"  
              11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "employed"  
              11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "unemployed"
              11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "employed"  
              11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "unemployed"
              11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "unemployed"
              11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "unemployed"
              11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "employed"  
              11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "employed"  
              11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "employed"  
              11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "unemployed"
              11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "unemployed"
              11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "employed"  
              11 3 1103 1 11 1987  6 1987  6 25 . 1 1987 "employed"  
              13 1 1301 1 10 1942 12 1942 12 70 . . 1942 "employed"  
              13 1 1301 1 10 1942 12 1942 12 70 . . 1942 "employed"  
              13 1 1301 1 10 1942 12 1942 12 70 . . 1942 "unemployed"
              13 1 1301 1 10 1942 12 1942 12 70 . . 1942 "unemployed"
              14 1 1401 1 10 1935 11 1935 12 77 . . 1935 "employed"  
              14 1 1401 1 10 1935 11 1935 12 77 . . 1935 "unemployed"
              14 1 1401 1 10 1935 11 1935 12 77 . . 1935 "employed"  
              14 1 1401 1 10 1935 11 1935 12 77 . . 1935 "unemployed"
              14 2 1402 2 20 1937  2 1937  4 75 1 . 1937 "unemployed"
              14 2 1402 2 20 1937  2 1937  4 75 1 . 1937 "unemployed"
              14 2 1402 2 20 1937  2 1937  4 75 1 . 1937 "employed"  
              14 2 1402 2 20 1937  2 1937  4 75 1 . 1937 "employed"  
            5048 1 1403 1 10 1972  2 1972  3 40 . . 1972 "employed"  
              15 2 1502 2 10 1955  3 1955  3 57 1 . 1955 "unemployed"
              15 2 1502 2 10 1955  3 1955  3 57 1 . 1955 "employed"  
              15 2 1502 2 10 1955  3 1955  3 57 1 . 1955 "employed"  
              15 3 1503 1 11 1979  9 1979  9 33 . 1    . "unemployed"
              15 3 1503 1 11 1979  9 1979  9 33 . 1    . "employed"  
              15 3 1503 1 11 1979  9 1979  9 33 . 1    . "employed"  
              15 3 1503 1 11 1979  9 1979  9 33 . 1    . "unemployed"
              15 3 1503 1 11 1979  9 1979  9 33 . 1    . "employed"  
              15 3 1503 1 11 1979  9 1979  9 33 . 1    . "employed"  
              15 3 1503 1 11 1979  9 1979  9 33 . 1    . "unemployed"
            end
            Thank you.

            Best,
            Bibek

            Comment


            • #7
              Thanks. I think we can make some progress with code now.

              As I understand it,

              * Duplicates on the variables used are not needed and will be a distraction.

              *. We can do nothing with households with just one person, as there is no comparison possible between man and child.

              Code:
              clear
              input int hhid15 byte hh_num int pid byte(gender relation) int dobylunar byte dobmlunar int dobysolar byte(dobmsolar age woman child) int p150104 str10 empstatus
                 1 1  101 2 10 1941 12 1942  2 71 1 . 1941 "employed"  
                 1 1  101 2 10 1941 12 1942  2 71 1 . 1941 "employed"  
                 1 1  101 2 10 1941 12 1942  2 71 1 . 1941 "employed"  
                 1 1  101 2 10 1941 12 1942  2 71 1 . 1941 "unemployed"
                 1 1  101 2 10 1941 12 1942  2 71 1 . 1941 "unemployed"
              7258 1  102 1 10 1968  3 1968  3 44 . . 1968 "unemployed"
              7258 1  102 1 10 1968  3 1968  3 44 . . 1968 "unemployed"
              7258 1  102 1 10 1968  3 1968  3 44 . . 1968 "employed"  
              7258 1  102 1 10 1968  3 1968  3 44 . . 1968 "employed"  
              7258 1  102 1 10 1968  3 1968  3 44 . . 1968 "employed"  
              6034 1  201 1 10 1951  8 1951  9 61 . . 1951 "unemployed"
              6034 1  201 1 10 1951  8 1951  9 61 . . 1951 "employed"  
              6034 1  201 1 10 1951  8 1951  9 61 . . 1951 "employed"  
              6034 1  201 1 10 1951  8 1951  9 61 . . 1951 "unemployed"
                 2 2  202 2 10 1954  3 1954  4 58 1 . 1954 "employed"  
                 4 1  401 1 10 1970  1 1970  1 42 . . 1970 "employed"  
                 4 2  402 2 20 1969 11 1969 12 43 1 . 1969 "employed"  
                 4 2  402 2 20 1969 11 1969 12 43 1 . 1969 "employed"  
                 4 2  402 2 20 1969 11 1969 12 43 1 . 1969 "unemployed"
                 4 3  403 1 11 1999  1 1999  1 13 . 1    . ""          
                 6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "unemployed"
                 6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "unemployed"
                 6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "unemployed"
                 6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "employed"  
                 6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "employed"  
                 6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "employed"  
                 6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "employed"  
                 6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "employed"  
                 6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "employed"  
                 6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "unemployed"
                 6 2  602 2 10 1935  2 1935  3 77 1 . 1935 "unemployed"
                 9 4  902 2 10 1970  1 1970  2 42 1 . 1970 "employed"  
              6056 1  903 2 20 1972  8 1972  9 40 1 . 1972 "employed"  
              6056 1  903 2 20 1972  8 1972  9 40 1 . 1972 "unemployed"
              6056 1  903 2 20 1972  8 1972  9 40 1 . 1972 "unemployed"
              6056 1  903 2 20 1972  8 1972  9 40 1 . 1972 "employed"  
              6056 1  903 2 20 1972  8 1972  9 40 1 . 1972 "employed"  
              6056 1  903 2 20 1972  8 1972  9 40 1 . 1972 "employed"  
              6056 1  903 2 20 1972  8 1972  9 40 1 . 1972 "unemployed"
                10 1 1001 2 10 1954  1 1954  2 58 1 . 1954 "unemployed"
                10 1 1001 2 10 1954  1 1954  2 58 1 . 1954 "employed"  
                11 1 1101 1 10 1957  1 1957  2 55 . . 1957 "employed"  
                11 1 1101 1 10 1957  1 1957  2 55 . . 1957 "employed"  
                11 1 1101 1 10 1957  1 1957  2 55 . . 1957 "unemployed"
                11 1 1101 1 10 1957  1 1957  2 55 . . 1957 "employed"  
                11 1 1101 1 10 1957  1 1957  2 55 . . 1957 "unemployed"
                11 1 1101 1 10 1957  1 1957  2 55 . . 1957 "employed"  
                11 1 1101 1 10 1957  1 1957  2 55 . . 1957 "unemployed"
                11 1 1101 1 10 1957  1 1957  2 55 . . 1957 "unemployed"
                11 1 1101 1 10 1957  1 1957  2 55 . . 1957 "employed"  
                11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "unemployed"
                11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "employed"  
                11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "employed"  
                11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "employed"  
                11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "unemployed"
                11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "employed"  
                11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "unemployed"
                11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "unemployed"
                11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "unemployed"
                11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "employed"  
                11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "employed"  
                11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "employed"  
                11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "unemployed"
                11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "unemployed"
                11 2 1102 2 20 1949  2 1949  3 63 1 . 1949 "employed"  
                11 3 1103 1 11 1987  6 1987  6 25 . 1 1987 "employed"  
                13 1 1301 1 10 1942 12 1942 12 70 . . 1942 "employed"  
                13 1 1301 1 10 1942 12 1942 12 70 . . 1942 "employed"  
                13 1 1301 1 10 1942 12 1942 12 70 . . 1942 "unemployed"
                13 1 1301 1 10 1942 12 1942 12 70 . . 1942 "unemployed"
                14 1 1401 1 10 1935 11 1935 12 77 . . 1935 "employed"  
                14 1 1401 1 10 1935 11 1935 12 77 . . 1935 "unemployed"
                14 1 1401 1 10 1935 11 1935 12 77 . . 1935 "employed"  
                14 1 1401 1 10 1935 11 1935 12 77 . . 1935 "unemployed"
                14 2 1402 2 20 1937  2 1937  4 75 1 . 1937 "unemployed"
                14 2 1402 2 20 1937  2 1937  4 75 1 . 1937 "unemployed"
                14 2 1402 2 20 1937  2 1937  4 75 1 . 1937 "employed"  
                14 2 1402 2 20 1937  2 1937  4 75 1 . 1937 "employed"  
              5048 1 1403 1 10 1972  2 1972  3 40 . . 1972 "employed"  
                15 2 1502 2 10 1955  3 1955  3 57 1 . 1955 "unemployed"
                15 2 1502 2 10 1955  3 1955  3 57 1 . 1955 "employed"  
                15 2 1502 2 10 1955  3 1955  3 57 1 . 1955 "employed"  
                15 3 1503 1 11 1979  9 1979  9 33 . 1    . "unemployed"
                15 3 1503 1 11 1979  9 1979  9 33 . 1    . "employed"  
                15 3 1503 1 11 1979  9 1979  9 33 . 1    . "employed"  
                15 3 1503 1 11 1979  9 1979  9 33 . 1    . "unemployed"
                15 3 1503 1 11 1979  9 1979  9 33 . 1    . "employed"  
                15 3 1503 1 11 1979  9 1979  9 33 . 1    . "employed"  
                15 3 1503 1 11 1979  9 1979  9 33 . 1    . "unemployed"
              end
              bysort hhid15 (pid) : drop if pid[1] == pid[_N]
              keep hhid15 pid age child gender
              duplicates drop
              egen n_men = total(gender == 1 & child == .), by(hhid15)
              tab n_men
              bysort hhid15: egen man_age = total(age * (gender == 1 & child == . & n_men == 1))
              by hhid15: egen first_child_age = max(age / child)
              gen diff_age = man_age - first_child_age
              egen tag = tag(hhid15)
              list hhid15 *age n_men if tag
              
                   +------------------------------------------------------+
                   | hhid15   age   man_age   first_~e   diff_age   n_men |
                   |------------------------------------------------------|
                1. |      4    42        42         13         29       1 |
                4. |     11    55        55         25         30       1 |
                7. |     14    77        77          .          .       1 |
                9. |     15    57         0         33        -33       0 |
                   +------------------------------------------------------+
              Code commentary:

              1. Drop households with just one person (first and last pid are the same)

              Code:
              bysort hhid15 (pid) : drop if pid[1] == pid[_N]
              2. Focus on variables we need

              Code:
              keep hhid15 pid age child gender
              3. Drop duplicates

              Code:
              duplicates drop
              4. A man is male and not a child: how many in each household

              Code:
              egen n_men = total(gender == 1 & child == .), by(hhid15)
              5. What are we supposed to do if 2 or more men, as who is father to whom?

              Code:
              tab n_men
              6. The age of the man is just the total of the ages, conditional on being a man and there being one man

              Code:
              bysort hhid15: egen man_age = total(age * (gender == 1 & child == . & n_men == 1))
              7. The first child is just the oldest.

              Code:
              by hhid15: egen first_child_age = max(age / child)
              Some would rather say
              Code:
              by hhid15: egen first_child_age = max(cond(child, age, .))
              More on that at http://www.stata-journal.com/sjpdf.h...iclenum=dm0055

              8. Difference is now just a subtraction as the values are in every observation

              Code:
              gen diff_age = man_age - first_child_age
              9. But we don't want multiple counting. See help on egen for this function.

              Code:
              egen tag = tag(hhid15)
              10. See what you got:

              Code:
              list hhid15 *age n_men if tag
              You could do a more exact calculation by using year and month of birth to get a monthly date using ym(). See help dates. Then work with a difference between monthly dates rather than a difference between ages. The first child then has the lowest monthly date of birth.

              11. No code here, but you would finally merge back with the original data.

              I wouldn't call these problems trivial. The two really important reasons why you were getting nowhere were already stated in #5:

              * Nothing in your code told Stata anything about comparison within households.

              * Subtraction won't work if the values are in different observations. You have to arrange that.

              In Stata terms, egen is your friend here, but study the article cited (and then cite it).





              Last edited by Nick Cox; 24 Mar 2016, 08:00.

              Comment


              • #8
                Hi Nick,

                Thank you so much for your reply. Forgive me if i understood it wrong but doesn't the diff_age show the age gap between a man and his first born child? whereas, I am looking for the age of a man at the time he had his first child (age at first birth).

                Somewhere around the code below but i still have problems making a connection. Hence, I get no observations at the end.

                Code:
                sort hhid15 pid
                 
                 *Man's birthdate
                by hhid15: gen birthyearman=dobylunar if man==1 & child==1 //'man' represents man in the household and 'child' represents first child
                 
                *Child's birthdate
                by hhid15: gen birthyearfchild=dobylunar if child==1 
                
                by hhid15: gen ageatfbirth=birthyearfchild-birthyearman
                tab ageatfbirth
                Code:
                * Example generated by -dataex-. To install: ssc install dataex
                clear
                input int hhid15 byte hh_num int pid byte gender int dobylunar byte dobmlunar int dobysolar byte(dobmsolar man woman child) str10 empstatus
                   1 1  101 2 1941 12 1942  2 . 1 . "employed"  
                   1 1  101 2 1941 12 1942  2 . 1 . "employed"  
                   1 1  101 2 1941 12 1942  2 . 1 . "employed"  
                   1 1  101 2 1941 12 1942  2 . 1 . "unemployed"
                   1 1  101 2 1941 12 1942  2 . 1 . "unemployed"
                7258 1  102 1 1968  3 1968  3 1 . . "unemployed"
                7258 1  102 1 1968  3 1968  3 . . . "unemployed"
                7258 1  102 1 1968  3 1968  3 . . . "employed"  
                7258 1  102 1 1968  3 1968  3 . . . "employed"  
                7258 1  102 1 1968  3 1968  3 . . . "employed"  
                6034 1  201 1 1951  8 1951  9 . . . "unemployed"
                6034 1  201 1 1951  8 1951  9 . . . "employed"  
                6034 1  201 1 1951  8 1951  9 . . . "employed"  
                6034 1  201 1 1951  8 1951  9 . . . "unemployed"
                   2 2  202 2 1954  3 1954  4 . 1 . "employed"  
                   4 1  401 1 1970  1 1970  1 . . . "employed"  
                   4 2  402 2 1969 11 1969 12 . 1 . "employed"  
                   4 2  402 2 1969 11 1969 12 . 1 . "employed"  
                   4 2  402 2 1969 11 1969 12 . 1 . "unemployed"
                   4 3  403 1 1999  1 1999  1 . . 1 ""          
                   6 2  602 2 1935  2 1935  3 . 1 . "unemployed"
                   6 2  602 2 1935  2 1935  3 . 1 . "unemployed"
                   6 2  602 2 1935  2 1935  3 1 1 . "unemployed"
                   6 2  602 2 1935  2 1935  3 . 1 . "employed"  
                   6 2  602 2 1935  2 1935  3 . 1 . "employed"  
                   6 2  602 2 1935  2 1935  3 . 1 . "employed"  
                   6 2  602 2 1935  2 1935  3 1 1 . "employed"  
                   6 2  602 2 1935  2 1935  3 1 1 . "employed"  
                   6 2  602 2 1935  2 1935  3 1 1 . "employed"  
                   6 2  602 2 1935  2 1935  3 1 1 . "unemployed"
                   6 2  602 2 1935  2 1935  3 1 1 . "unemployed"
                   9 4  902 2 1970  1 1970  2 1 1 . "employed"  
                6056 1  903 2 1972  8 1972  9 1 1 . "employed"  
                6056 1  903 2 1972  8 1972  9 1 1 . "unemployed"
                6056 1  903 2 1972  8 1972  9 1 1 . "unemployed"
                6056 1  903 2 1972  8 1972  9 . 1 . "employed"  
                6056 1  903 2 1972  8 1972  9 . 1 . "employed"  
                6056 1  903 2 1972  8 1972  9 . 1 . "employed"  
                6056 1  903 2 1972  8 1972  9 . 1 . "unemployed"
                  10 1 1001 2 1954  1 1954  2 . 1 . "unemployed"
                  10 1 1001 2 1954  1 1954  2 . 1 . "employed"  
                  11 1 1101 1 1957  1 1957  2 . . . "employed"  
                  11 1 1101 1 1957  1 1957  2 . . . "employed"  
                  11 1 1101 1 1957  1 1957  2 . . . "unemployed"
                  11 1 1101 1 1957  1 1957  2 . . . "employed"  
                  11 1 1101 1 1957  1 1957  2 . . . "unemployed"
                  11 1 1101 1 1957  1 1957  2 . . . "employed"  
                  11 1 1101 1 1957  1 1957  2 . . . "unemployed"
                  11 1 1101 1 1957  1 1957  2 . . . "unemployed"
                  11 1 1101 1 1957  1 1957  2 . . . "employed"  
                  11 2 1102 2 1949  2 1949  3 . 1 . "unemployed"
                  11 2 1102 2 1949  2 1949  3 1 1 . "employed"  
                  11 2 1102 2 1949  2 1949  3 1 1 . "employed"  
                  11 2 1102 2 1949  2 1949  3 1 1 . "employed"  
                  11 2 1102 2 1949  2 1949  3 1 1 . "unemployed"
                  11 2 1102 2 1949  2 1949  3 1 1 . "employed"  
                  11 2 1102 2 1949  2 1949  3 1 1 . "unemployed"
                  11 2 1102 2 1949  2 1949  3 1 1 . "unemployed"
                  11 2 1102 2 1949  2 1949  3 1 1 . "unemployed"
                  11 2 1102 2 1949  2 1949  3 . 1 . "employed"  
                  11 2 1102 2 1949  2 1949  3 . 1 . "employed"  
                  11 2 1102 2 1949  2 1949  3 . 1 . "employed"  
                  11 2 1102 2 1949  2 1949  3 . 1 . "unemployed"
                  11 2 1102 2 1949  2 1949  3 . 1 . "unemployed"
                  11 2 1102 2 1949  2 1949  3 . 1 . "employed"  
                  11 3 1103 1 1987  6 1987  6 . . 1 "employed"  
                  13 1 1301 1 1942 12 1942 12 . . . "employed"  
                  13 1 1301 1 1942 12 1942 12 . . . "employed"  
                  13 1 1301 1 1942 12 1942 12 . . . "unemployed"
                  13 1 1301 1 1942 12 1942 12 . . . "unemployed"
                  14 1 1401 1 1935 11 1935 12 . . . "employed"  
                  14 1 1401 1 1935 11 1935 12 . . . "unemployed"
                  14 1 1401 1 1935 11 1935 12 . . . "employed"  
                  14 1 1401 1 1935 11 1935 12 . . . "unemployed"
                  14 2 1402 2 1937  2 1937  4 . 1 . "unemployed"
                  14 2 1402 2 1937  2 1937  4 . 1 . "unemployed"
                  14 2 1402 2 1937  2 1937  4 . 1 . "employed"  
                  14 2 1402 2 1937  2 1937  4 . 1 . "employed"  
                5048 1 1403 1 1972  2 1972  3 . . . "employed"  
                  15 2 1502 2 1955  3 1955  3 . 1 . "unemployed"
                  15 2 1502 2 1955  3 1955  3 . 1 . "employed"  
                  15 2 1502 2 1955  3 1955  3 . 1 . "employed"  
                  15 3 1503 1 1979  9 1979  9 . . 1 "unemployed"
                  15 3 1503 1 1979  9 1979  9 . . 1 "employed"  
                  15 3 1503 1 1979  9 1979  9 . . 1 "employed"  
                  15 3 1503 1 1979  9 1979  9 . . 1 "unemployed"
                  15 3 1503 1 1979  9 1979  9 . . 1 "employed"  
                  15 3 1503 1 1979  9 1979  9 . . 1 "employed"  
                  15 3 1503 1 1979  9 1979  9 . . 1 "unemployed"
                end

                Best,
                Bibek

                Comment


                • #9
                  It's the same thing. My father was 34 when his first child was born and remained that much older. I take that to be a general rule.

                  Comment


                  • #10
                    Thank you so much. Your codes along with explanations were very helpful and I also managed to solve it in a different way.

                    I have another question on first birth.

                    I want to create a variable with man's employment status at the time of first birth. Whether a man was employed or unemployed at the time when he had his first child.
                    The problem here is the variable empstatus is connected with the variables earliest and latest that shows from which year to which year an individual was employed or unemployed. For example
                    pid 101 was unemployed from 2005m6-2006m12 (earliest to latest)
                    pid 101 was employed from 2003m1-2005m5 (earliest to latest)

                    How to create a variable (emp. status at the time of first birth) to show that for example if pid 101 had a first birth at 2005m8 then he was employed?

                    sample of my dataset

                    Variable
                    dobylunar: date of birth year lunar
                    dobmlunar: date of birth month lunar


                    Code:
                    * Example generated by -dataex-. To install: ssc install dataex
                    clear
                    input long(hhid15 pid) int dobylunar byte dobmlunar int age float(Man Child earliest latest) str10 empstatus float(type workplace birthyearman birthyearfchild ageatfbirth)
                         1      101 1941 12  71 . .  345  516 "employed"   1 2    .    .  .
                         1      101 1941 12  71 . .  537  559 "employed"   2 5    .    .  .
                         1      101 1941 12  71 . .  560    1 "unemployed" 3 5    .    .  .
                         1      101 1941 12  71 . .  517  536 "unemployed" 3 4    .    .  .
                         2      202 1954  3  58 . .  506    1 "employed"   1 2    .    .  .
                         4      401 1970  1  42 1 .  435    1 "employed"   1 1 1970    . 29
                         4      402 1969 11  43 . .  389  449 "employed"   1 2    .    .  .
                         4      402 1969 11  43 . .  450  500 "unemployed" 3 4    .    .  .
                         4      402 1969 11  43 . .  501    1 "employed"   2 5    .    .  .
                         4      403 1999  1  13 . 1    .    . ""           . .    . 1999  .
                         6      602 1935  2  77 . .  484  577 "unemployed" 3 4    .    .  .
                         6      602 1935  2  77 . .  456  475 "unemployed" 3 4    .    .  .
                         6      602 1935  2  77 . .  476  483 "employed"   1 2    .    .  .
                         6      602 1935  2  77 . .  602    1 "employed"   1 1    .    .  .
                         6      602 1935  2  77 . .  -15  -16 "unemployed" 3 5    .    .  .
                         6      602 1935  2  77 . .  -57  -16 "employed"   2 5    .    .  .
                         6      602 1935  2  77 . .  -15  455 "employed"   2 2    .    .  .
                         6      602 1935  2  77 . .  -57  -58 "unemployed" 3 5    .    .  .
                         6      602 1935  2  77 . .  578  601 "employed"   1 2    .    .  .
                         6      602 1935  2  77 . .  602  601 "unemployed" 3 4    .    .  .
                         6      602 1935  2  77 . .  -82  -58 "employed"   1 5    .    .  .
                         9      902 1970  1  42 . .  458    1 "employed"   1 2    .    .  .
                         9   501401 1966 12  46 1 .  410    1 "employed"   1 2 1966    . 33
                         9   501403 1999 10  13 . 1    .    . ""           . .    . 1999  .
                        10     1001 1954  1  58 . .  620    1 "unemployed" 3 4    .    .  .
                        10     1001 1954  1  58 . .  177  619 "employed"   1 2    .    .  .
                        11     1101 1957  1  55 1 .  435  434 "unemployed" 3 5 1957    . 30
                        11     1101 1957  1  55 1 .  472  491 "employed"   1 2 1957    . 30
                        11     1101 1957  1  55 1 .  492  491 "unemployed" 3 4 1957    . 30
                        11     1101 1957  1  55 1 .  435  461 "employed"   1 2 1957    . 30
                        11     1101 1957  1  55 1 .  314  422 "employed"   1 5 1957    . 30
                        11     1101 1957  1  55 1 .  423  422 "unemployed" 3 5 1957    . 30
                        11     1101 1957  1  55 1 .  492    1 "employed"   1 2 1957    . 30
                        11     1101 1957  1  55 1 .  462  471 "unemployed" 3 4 1957    . 30
                        11     1101 1957  1  55 1 .  423  434 "employed"   1 5 1957    . 30
                        11     1102 1949  2  63 . .  606    1 "employed"   1 2    .    .  .
                        11     1102 1949  2  63 . .  473  485 "employed"   1 2    .    .  .
                        11     1102 1949  2  63 . .  462  462 "unemployed" 3 5    .    .  .
                        11     1102 1949  2  63 . .  472  472 "unemployed" 3 4    .    .  .
                        11     1102 1949  2  63 . .  557  605 "unemployed" 3 4    .    .  .
                        11     1102 1949  2  63 . .  501  532 "employed"   1 2    .    .  .
                        11     1102 1949  2  63 . .  543  543 "unemployed" 3 4    .    .  .
                        11     1102 1949  2  63 . .  486  493 "unemployed" 3 4    .    .  .
                        11     1102 1949  2  63 . .  533  532 "unemployed" 3 4    .    .  .
                        11     1102 1949  2  63 . .  463  471 "employed"   1 2    .    .  .
                        11     1102 1949  2  63 . .  494  500 "employed"   1 3    .    .  .
                        11     1102 1949  2  63 . .  501  500 "unemployed" 3 4    .    .  .
                        11     1102 1949  2  63 . .  533  542 "employed"   1 2    .    .  .
                        11     1102 1949  2  63 . .  435  461 "employed"   1 5    .    .  .
                        11     1102 1949  2  63 . .  544  556 "employed"   1 2    .    .  .
                        11     1103 1987  6  25 . 1  625    1 "employed"   1 2    . 1987  .
                        13     1301 1942 12  70 1 .  477  531 "employed"   2 5 1942    .  .
                        13     1301 1942 12  70 1 .  455  476 "unemployed" 3 4 1942    .  .
                        13     1301 1942 12  70 1 .  206  454 "employed"   2 2 1942    .  .
                        13     1301 1942 12  70 1 .  532    1 "unemployed" 3 5 1942    .  .
                        14     1401 1935 11  77 1 .  477  479 "employed"   2 5 1935    .  .
                        14     1401 1935 11  77 1 .  480    1 "unemployed" 3 5 1935    .  .
                        14     1401 1935 11  77 1 .  474  476 "unemployed" 3 5 1935    .  .
                        14     1401 1935 11  77 1 .  230  473 "employed"   2 5 1935    .  .
                        14     1402 1937  2  75 . .  480    1 "unemployed" 3 5    .    .  .
                        14     1402 1937  2  75 . .  474  476 "unemployed" 3 5    .    .  .
                        14     1402 1937  2  75 . .  281  473 "employed"   2 5    .    .  .
                        14     1402 1937  2  75 . .  477  479 "employed"   2 5    .    .  .
                        15     1502 1955  3  57 . .  451  487 "employed"   1 2    .    .  .
                        15     1502 1955  3  57 . .  555    1 "employed"   1 2    .    .  .
                        15     1502 1955  3  57 . .  488  554 "unemployed" 3 4    .    .  .
                        15     1503 1979  9  33 . 1  540  539 "unemployed" 3 4    . 1979  .
                        15     1503 1979  9  33 . 1  527  539 "employed"   1 2    . 1979  .
                        15     1503 1979  9  33 . 1  540  558 "employed"   1 2    . 1979  .
                        15     1503 1979  9  33 . 1  520  526 "unemployed" 3 4    . 1979  .
                        15     1503 1979  9  33 . 1  559    1 "employed"   1 2    . 1979  .
                        15     1503 1979  9  33 . 1  505  519 "employed"   1 2    . 1979  .
                        15     1503 1979  9  33 . 1  559  558 "unemployed" 3 4    . 1979  .
                        16     1601 1948 10  64 . .  461  479 "employed"   2 5    .    .  .
                        16     1601 1948 10  64 . .  607  610 "unemployed" 3 5    .    .  .
                        16     1601 1948 10  64 . .  611  617 "employed"   2 5    .    .  .
                        16     1601 1948 10  64 . .  527  606 "employed"   2 5    .    .  .
                        16     1601 1948 10  64 . .  621  624 "employed"   1 2    .    .  .
                        16     1601 1948 10  64 . .  438  454 "unemployed" 3 5    .    .  .
                        16     1601 1948 10  64 . .  485  526 "employed"   1 2    .    .  .
                        16     1601 1948 10  64 . .  618  620 "unemployed" 3 5    .    .  .
                        16     1601 1948 10  64 . .  527  526 "unemployed" 3 4    .    .  .
                        16     1601 1948 10  64 . .  625  628 "unemployed" 3 4    .    .  .
                        16     1601 1948 10  64 . .  458  460 "unemployed" 3 5    .    .  .
                        16     1601 1948 10  64 . .  480  484 "unemployed" 3 5    .    .  .
                        16     1601 1948 10  64 . .  353  413 "employed"   2 5    .    .  .
                        16     1601 1948 10  64 . .  425  437 "employed"   2 5    .    .  .
                        16     1601 1948 10  64 . .  341  341 "employed"   1 5    .    .  .
                        16     1601 1948 10  64 . .  342  352 "unemployed" 3 5    .    .  .
                        16     1601 1948 10  64 . .  629    1 "employed"   1 2    .    .  .
                        16     1601 1948 10  64 . .  455  457 "employed"   2 5    .    .  .
                        16     1601 1948 10  64 . .  414  424 "unemployed" 3 5    .    .  .
                        18     1801 1945  3  67 1 .  600    1 "unemployed" 3 4 1945    . 27
                        18     1801 1945  3  67 1 .  470  599 "employed"   1 2 1945    . 27
                        18     1801 1945  3  67 1 .   29  455 "employed"   1 3 1945    . 27
                        18     1801 1945  3  67 1 .  456  469 "unemployed" 3 4 1945    . 27
                        18     1802 1950  9  62 . .  618    1 "employed"   1 1    .    .  .
                        18     1802 1950  9  62 . .  492  576 "employed"   1 2    .    .  .
                        18     1802 1950  9  62 . .  593  607 "employed"   1 1    .    .  .
                        18     1802 1950  9  62 . .  577  592 "unemployed" 3 4    .    .  .
                        18     1802 1950  9  62 . .  608  617 "unemployed" 3 4    .    .  .
                        18     1802 1950  9  62 . .  386  422 "employed"   1 2    .    .  .
                        18     1802 1950  9  62 . .  423  491 "unemployed" 3 4    .    .  .
                        18     1803 1972 10  40 . 1  502  505 "unemployed" 3 4    . 1972  .
                        18     1803 1972 10  40 . 1  349  421 "employed"   1 5    . 1972  .
                        18     1803 1972 10  40 . 1  506    1 "employed"   1 2    . 1972  .
                        18     1803 1972 10  40 . 1  422  421 "unemployed" 3 5    . 1972  .
                        18     1803 1972 10  40 . 1  422  501 "employed"   1 2    . 1972  .
                        18     1804    .  .   . . .  475  508 "employed"   1 2    .    .  .
                        18     1804    .  .   . . .  607    1 "employed"   1 2    .    .  .
                        18     1804    .  .   . . .  521  576 "unemployed" 3 4    .    .  .
                        18     1804    .  .   . . .  596  606 "unemployed" 3 4    .    .  .
                        18     1804    .  .   . . .  518  520 "employed"   1 2    .    .  .
                        18     1804    .  .   . . .  470  473 "employed"   1 3    .    .  .
                        18     1804    .  .   . . .  509  517 "unemployed" 3 4    .    .  .
                        18     1804    .  .   . . .  577  595 "employed"   1 2    .    .  .
                        18     1804    .  .   . . .  474  474 "unemployed" 3 4    .    .  .
                        18     1805    .  .   . . .  542  551 "employed"   1 2    .    .  .
                        18     1805    .  .   . . .  494  518 "employed"   1 2    .    .  .
                        18     1805    .  .   . . .  519  541 "unemployed" 3 4    .    .  .
                        18     1805    .  .   . . .  552    1 "unemployed" 3 4    .    .  .
                        20     2001 1962  1  50 1 .  506  505 "unemployed" 3 4 1962    . 30
                        20     2001 1962  1  50 1 .  557  558 "employed"   1 2 1962    . 30
                        20     2001 1962  1  50 1 .  303  505 "employed"   1 2 1962    . 30
                        20     2001 1962  1  50 1 .  297  302 "unemployed" 3 5 1962    . 30
                        20     2001 1962  1  50 1 .  559    1 "employed"   1 2 1962    . 30
                        20     2001 1962  1  50 1 .  506  556 "employed"   1 2 1962    . 30
                        20     2001 1962  1  50 1 .  557  556 "unemployed" 3 4 1962    . 30
                        20     2001 1962  1  50 1 .  285  296 "employed"   1 5 1962    . 30
                        20     2001 1962  1  50 1 .  559  558 "unemployed" 3 4 1962    . 30
                        20     2002 1958 11  54 . .  338  482 "employed"   2 5    .    .  .
                        20     2002 1958 11  54 . .  559    1 "employed"   1 2    .    .  .
                        20     2002 1958 11  54 . .  483  493 "unemployed" 3 5    .    .  .
                        20     2002 1958 11  54 . .  557  556 "unemployed" 3 4    .    .  .
                        20     2002 1958 11  54 . .  557  558 "employed"   1 2    .    .  .
                        20     2002 1958 11  54 . .  231  262 "employed"   1 5    .    .  .
                        20     2002 1958 11  54 . .  263  337 "unemployed" 3 5    .    .  .
                        20     2002 1958 11  54 . .  559  558 "unemployed" 3 4    .    .  .
                        20     2002 1958 11  54 . .  494  505 "employed"   1 2    .    .  .
                        20     2002 1958 11  54 . .  506  505 "unemployed" 3 4    .    .  .
                        20     2002 1958 11  54 . .  506  556 "employed"   1 2    .    .  .
                        20     2003 1992  4  20 . 1  617    1 "employed"   1 2    . 1992  .
                        20     2004    .  .   . . .    .    . ""           . .    .    .  .
                        22     2201 1973  6  39 . .  556    1 "employed"   1 2    .    .  .
                        22     2201 1973  6  39 . .  443  524 "employed"   2 5    .    .  .
                        22     2201 1973  6  39 . .  525  555 "unemployed" 3 5    .    .  .
                        22     2202 1967  3  45 1 .  425  459 "employed"   1 5 1967    . 33
                        22     2202 1967  3  45 1 .  536  537 "unemployed" 3 5 1967    . 33
                        22     2202 1967  3  45 1 .  538  572 "employed"   1 2 1967    . 33
                        22     2202 1967  3  45 1 .  573    1 "employed"   2 5 1967    . 33
                        22     2202 1967  3  45 1 .  460  464 "unemployed" 3 5 1967    . 33
                        22     2202 1967  3  45 1 .  465  535 "employed"   2 5 1967    . 33
                        22     2202 1967  3  45 1 .  573  572 "unemployed" 3 4 1967    . 33
                        22     2203 2000  8  12 . 1    .    . ""           . .    . 2000  .
                        24     2401 1919  8  93 1 . -138    5 "employed"   1 5 1919    .  .
                        24     2401 1919  8  93 1 .  113  305 "employed"   2 3 1919    .  .
                        24     2401 1919  8  93 1 .    6  112 "unemployed" 3 5 1919    .  .
                        24     2401 1919  8  93 1 .  306    1 "unemployed" 3 4 1919    .  .
                        24     2402 1933 11  79 . .  113  305 "employed"   2 3    .    .  .
                        24     2402 1933 11  79 . .  306    1 "unemployed" 3 4    .    .  .
                        27     2702 1938 11  74 . .  492  530 "employed"   1 3    .    .  .
                        27     2702 1938 11  74 . .  531    1 "unemployed" 3 4    .    .  .
                        27     2702 1938 11  74 . .  483  491 "employed"   1 1    .    .  .
                        27     2702 1938 11  74 . .  492  491 "unemployed" 3 4    .    .  .
                        27     2703    .  .   . . .  526  571 "unemployed" 3 5    .    .  .
                        27     2703    .  .   . . .  572    1 "employed"   1 2    .    .  .
                        27     2703    .  .   . . .  519  525 "employed"   1 5    .    .  .
                        27     2703    .  .   . . .  470  518 "employed"   1 5    .    .  .
                        27     2703    .  .   . . .  519  518 "unemployed" 3 5    .    .  .
                        28     2802 1935  3  77 . .  -54    1 "unemployed" 3 4    .    .  .
                        28     2802 1935  3  77 . .  -55  -55 "employed"   1 2    .    .  .
                        29     2902 1932  1  80 . .  252    1 "unemployed" 3 4    .    .  .
                        29     2902 1932  1  80 . .  162  170 "unemployed" 3 5    .    .  .
                        29     2902 1932  1  80 . .  125  161 "employed"   1 5    .    .  .
                        29     2902 1932  1  80 . .  171  251 "employed"   2 3    .    .  .

                    Thank you.

                    Best,
                    Bibek

                    Comment


                    • #11
                      Dear Statalist,

                      To reformulate my question:

                      I want to create a variable that shows Man's employment status at the time of first birth (if he had any Child). The variables in the dataset earliest and latest shows the time period an individual was employed or unemployed (empstatus).


                      Thank you.

                      Best regards,
                      Bibek

                      Comment

                      Working...
                      X