Announcement

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

  • Merging the BR with CR FILES

    I need assistance with merging the BR file and the CR file from DHS, but I'm unsure which variables to use as the key variables.

  • #2
    Behar,

    Try this
    Code:
    use "CR", clear 
    merge 1:m caseid using "BR", keep(match) nogen
    The key variable in the CR data is caseid, while the key variables in the BR data are caseid and bord (birth order).
    Next time, please provide an example of your data. Otherwise, you may not receive a response, as people here may not be familiar with the DHS.

    Hope this helps.

    Comment


    • #3
      I am working with a dataset in long format (BR file) where each observation represents an individual child. The variable bord identifies the birth order of the child. I also have another dataset (CR file) that contains male characteristics (e.g., father's education, father's age, type of marital setup—monogamous or polygamous).

      I want to merge these two datasets to:
      1. Add the husband's characteristics to the BR file by matching them appropriately (e.g., using caseid or another identifier).
      2. Retain the bord variable and keep the data in long format, where each row corresponds to a child.
      3. Be able to identify whether the couple lives in a monogamous or polygamous setup after the merge.
      How can I achieve this in Stata? Any guidance on the merge process and ensuring the datasets remain in long format would be greatly appreciated.
      now i present my datasets below
      . dataex

      ----------------------- copy starting from the next line -----------------------
      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input str15 caseid str3 v000 int v001 byte(v002 v003 v201) int(b11 b12)
      "       1   1  2" "PK7" 1  1 2 5  68   .
      "       1   1  2" "PK7" 1  1 2 5  23  68
      "       1   1  2" "PK7" 1  1 2 5  25  23
      "       1   1  2" "PK7" 1  1 2 5  26  25
      "       1   1  2" "PK7" 1  1 2 5   .  26
      "       1   4  1" "PK7" 1  4 1 5  26   .
      "       1   4  1" "PK7" 1  4 1 5  66  26
      "       1   4  1" "PK7" 1  4 1 5  24  66
      "       1   4  1" "PK7" 1  4 1 5  28  24
      "       1   4  1" "PK7" 1  4 1 5   .  28
      "       1   5  2" "PK7" 1  5 2 5  30   .
      "       1   5  2" "PK7" 1  5 2 5  11  30
      "       1   5  2" "PK7" 1  5 2 5  31  11
      "       1   5  2" "PK7" 1  5 2 5  49  31
      "       1   5  2" "PK7" 1  5 2 5   .  49
      "       1   6  2" "PK7" 1  6 2 4  49   .
      "       1   6  2" "PK7" 1  6 2 4  38  49
      "       1   6  2" "PK7" 1  6 2 4  50  38
      "       1   6  2" "PK7" 1  6 2 4   .  50
      "       1   8  4" "PK7" 1  8 4 1   .   .
      "       1   8  7" "PK7" 1  8 7 1   .   .
      "       1   9  4" "PK7" 1  9 4 4  19   .
      "       1   9  4" "PK7" 1  9 4 4  30  19
      "       1   9  4" "PK7" 1  9 4 4  58  30
      "       1   9  4" "PK7" 1  9 4 4   .  58
      "       1  10  2" "PK7" 1 10 2 5  50   .
      "       1  10  2" "PK7" 1 10 2 5  25  50
      "       1  10  2" "PK7" 1 10 2 5  51  25
      "       1  10  2" "PK7" 1 10 2 5  16  51
      "       1  10  2" "PK7" 1 10 2 5   .  16
      "       1  10  7" "PK7" 1 10 7 2  46   .
      "       1  10  7" "PK7" 1 10 7 2   .  46
      "       1  11  1" "PK7" 1 11 1 6  24   .
      "       1  11  1" "PK7" 1 11 1 6  67  24
      "       1  11  1" "PK7" 1 11 1 6  19  67
      "       1  11  1" "PK7" 1 11 1 6  31  19
      "       1  11  1" "PK7" 1 11 1 6  22  31
      "       1  11  1" "PK7" 1 11 1 6   .  22
      "       1  12  2" "PK7" 1 12 2 2  30   .
      "       1  12  2" "PK7" 1 12 2 2   .  30
      "       1  14  2" "PK7" 1 14 2 4   9   .
      "       1  14  2" "PK7" 1 14 2 4  21   9
      "       1  14  2" "PK7" 1 14 2 4  21  21
      "       1  14  2" "PK7" 1 14 2 4   .  21
      "       1  15  2" "PK7" 1 15 2 5  10   .
      "       1  15  2" "PK7" 1 15 2 5  57  10
      "       1  15  2" "PK7" 1 15 2 5  52  57
      "       1  15  2" "PK7" 1 15 2 5  22  52
      "       1  15  2" "PK7" 1 15 2 5   .  22
      "       1  19  2" "PK7" 1 19 2 6  32   .
      "       1  19  2" "PK7" 1 19 2 6  31  32
      "       1  19  2" "PK7" 1 19 2 6  18  31
      "       1  19  2" "PK7" 1 19 2 6  28  18
      "       1  19  2" "PK7" 1 19 2 6  50  28
      "       1  19  2" "PK7" 1 19 2 6   .  50
      "       1  20  4" "PK7" 1 20 4 5  34   .
      "       1  20  4" "PK7" 1 20 4 5  78  34
      "       1  20  4" "PK7" 1 20 4 5  28  78
      "       1  20  4" "PK7" 1 20 4 5  24  28
      "       1  20  4" "PK7" 1 20 4 5   .  24
      "       1  21  4" "PK7" 1 21 4 2  32   .
      "       1  21  4" "PK7" 1 21 4 2   .  32
      "       1  22  1" "PK7" 1 22 1 4  49   .
      "       1  22  1" "PK7" 1 22 1 4  17  49
      "       1  22  1" "PK7" 1 22 1 4  93  17
      "       1  22  1" "PK7" 1 22 1 4   .  93
      "       1  23  2" "PK7" 1 23 2 5  58   .
      "       1  23  2" "PK7" 1 23 2 5  48  58
      "       1  23  2" "PK7" 1 23 2 5  14  48
      "       1  23  2" "PK7" 1 23 2 5  23  14
      "       1  23  2" "PK7" 1 23 2 5   .  23
      "       1  24  2" "PK7" 1 24 2 6 115   .
      "       1  24  2" "PK7" 1 24 2 6  31 115
      "       1  24  2" "PK7" 1 24 2 6  14  31
      "       1  24  2" "PK7" 1 24 2 6  14  14
      "       1  24  2" "PK7" 1 24 2 6 115  14
      "       1  24  2" "PK7" 1 24 2 6   . 115
      "       1  24  3" "PK7" 1 24 3 1   .   .
      "       1  25  2" "PK7" 1 25 2 3  87   .
      "       1  25  2" "PK7" 1 25 2 3  55  87
      "       1  25  2" "PK7" 1 25 2 3   .  55
      "       1  27  2" "PK7" 1 27 2 2  63   .
      "       1  27  2" "PK7" 1 27 2 2   .  63
      "       1  27  5" "PK7" 1 27 5 1   .   .
      "       1  28  2" "PK7" 1 28 2 3  49   .
      "       1  28  2" "PK7" 1 28 2 3  24  49
      "       1  28  2" "PK7" 1 28 2 3   .  24
      "       2   1  2" "PK7" 2  1 2 5  29   .
      "       2   1  2" "PK7" 2  1 2 5  74  29
      "       2   1  2" "PK7" 2  1 2 5  31  74
      "       2   1  2" "PK7" 2  1 2 5  25  31
      "       2   1  2" "PK7" 2  1 2 5   .  25
      "       2   3  2" "PK7" 2  3 2 1   .   .
      "       2   4  2" "PK7" 2  4 2 3  29   .
      "       2   4  2" "PK7" 2  4 2 3  26  29
      "       2   4  2" "PK7" 2  4 2 3   .  26
      "       2   6  2" "PK7" 2  6 2 3  57   .
      "       2   6  2" "PK7" 2  6 2 3  39  57
      "       2   6  2" "PK7" 2  6 2 3   .  39
      "       2   8  2" "PK7" 2  8 2 4  12   .
      end
      ------------------ copy up to and including the previous line ------------------

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

      .
      . dataex caseid v000 v001 v004 w_highest_edu w_highest_edu_year age_of_household_hea
      > d m_wealth_index v201 consanguinity m_unions

      ----------------------- copy starting from the next line -----------------------
      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input str15 caseid str3 v000 int(v001 v004) byte(w_highest_edu w_highest_edu_year age_of_household_head) long m_wealth_index byte(v201 consanguinity m_unions)
      "       1   1  2" "PK7"  1  1 2 5 44  -98851  5 1 1
      "       1   7  2" "PK7"  1  1 0 . 43  -69725  0 0 2
      "       1  21  4" "PK7"  1  1 3 4 61  -41103  2 0 1
      "       2   1  2" "PK7"  2  2 0 . 32  -77082  5 1 1
      "       2   4  2" "PK7"  2  2 1 5 43   -7020  3 0 1
      "       2  18  5" "PK7"  2  2 2 4 78  -57736  0 0 1
      "       2  21  2" "PK7"  2  2 3 6 43   25018  2 0 1
      "       2  24  2" "PK7"  2  2 3 2 47 -134784  3 0 1
      "       3   7  2" "PK7"  3  3 0 . 39   -9169  4 0 1
      "       3  13  4" "PK7"  3  3 1 4 66   56327  0 0 1
      "       3  18  2" "PK7"  3  3 0 . 22  -56333  1 1 1
      "       3  21  2" "PK7"  3  3 0 . 36  -56966  3 0 1
      "       3  24  4" "PK7"  3  3 0 . 56  -81781  2 1 1
      "       3  27  4" "PK7"  3  3 0 . 66  -55561  3 0 1
      "       3  27  9" "PK7"  3  3 0 . 66  -55561  0 1 1
      "       4   1  2" "PK7"  4  4 0 . 46  -96194  7 0 1
      "       4   4  2" "PK7"  4  4 0 . 30  -53458  5 0 1
      "       4   7  2" "PK7"  4  4 0 . 47 -131698  5 1 1
      "       4  10  2" "PK7"  4  4 0 . 48 -132436  9 1 1
      "       4  21  4" "PK7"  4  4 0 . 67  -85827  0 1 1
      "       4  24  2" "PK7"  4  4 0 . 31 -111778  2 1 1
      "       4  24  6" "PK7"  4  4 0 . 31 -111778  0 0 1
      "       4  27  2" "PK7"  4  4 0 . 39  -94398  6 1 1
      "       5  10  2" "PK7"  5  5 0 . 45   18312  8 0 1
      "       5  15  2" "PK7"  5  5 0 . 29  118506  3 1 1
      "       5  21  2" "PK7"  5  5 1 3 30  -58555  2 1 1
      "       6   4  2" "PK7"  6  6 0 . 30 -122390  4 1 1
      "       6   7  4" "PK7"  6  6 0 . 90  -90748  3 1 1
      "       6  15  2" "PK7"  6  6 0 . 23 -132463  0 1 1
      "       6  18  2" "PK7"  6  6 0 . 33 -135968  2 1 1
      "       6  21  4" "PK7"  6  6 0 . 62  -76177  1 1 1
      "       6  24  4" "PK7"  6  6 0 . 60  -52181  0 1 1
      "       7   1  3" "PK7"  7  7 3 3 56   59021  4 0 1
      "       7   4  3" "PK7"  7  7 3 4 57  206881  4 1 1
      "       7   4 10" "PK7"  7  7 3 2 57  206881  1 1 1
      "       7  10  2" "PK7"  7  7 2 4 31  157451  2 0 1
      "       7  18  2" "PK7"  7  7 2 5 43   48693  4 1 1
      "       7  27  2" "PK7"  7  7 2 3 23   65480  2 1 1
      "       8   1  2" "PK7"  8  8 0 . 40   21409  6 0 1
      "       8   4  3" "PK7"  8  8 1 5 63   99309  7 1 1
      "       8  10  2" "PK7"  8  8 2 5 46  185678  6 0 1
      "       8  13  4" "PK7"  8  8 3 4 61  166698  1 1 1
      "       8  13  8" "PK7"  8  8 3 3 61  166698  0 1 1
      "       8  13 10" "PK7"  8  8 3 2 61  166698  0 1 1
      "       8  15  8" "PK7"  8  8 0 . 61   54807  2 1 1
      "       9  10  2" "PK7"  9  9 2 4 45   66097  3 1 1
      "       9  15  7" "PK7"  9  9 1 5 52   90287  0 1 1
      "       9  21  4" "PK7"  9  9 0 . 55  123900  1 0 1
      "      10   7  2" "PK7" 10 10 0 . 32  -89776  4 1 1
      "      10  10  2" "PK7" 10 10 2 5 35   30246  2 1 1
      "      10  24  9" "PK7" 10 10 1 5 55    2390  2 1 1
      "      11   4  2" "PK7" 11 11 0 . 48   11582  6 1 1
      "      11   7  2" "PK7" 11 11 1 5 42 -165498  5 0 1
      "      11  15  3" "PK7" 11 11 0 . 60   11243  1 1 1
      "      11  21  2" "PK7" 11 11 0 . 42   16947  7 0 1
      "      11  24  4" "PK7" 11 11 2 2 72    5880  4 1 1
      "      11  24 10" "PK7" 11 11 1 4 72    5880  2 1 1
      "      12  10  3" "PK7" 12 12 0 . 70 -155692  6 0 1
      "      12  13 13" "PK7" 12 12 2 4 75   -2429  0 1 1
      "      12  15  4" "PK7" 12 12 3 6 69   67673  2 1 1
      "      12  21  2" "PK7" 12 12 0 . 38 -132940  3 1 1
      "      13   4  8" "PK7" 13 13 0 . 65 -272058  2 1 1
      "      13  10  6" "PK7" 13 13 1 5 62  -76933  0 1 1
      "      13  15  2" "PK7" 13 13 2 4 36   -9170  4 0 1
      "      13  18  4" "PK7" 13 13 1 4 60  -25952  6 1 1
      "      13  18 14" "PK7" 13 13 2 3 60  -25952  0 1 1
      "      13  24  2" "PK7" 13 13 3 2 42   13048  3 1 1
      "      14  10  2" "PK7" 14 14 1 5 25  102301  1 1 1
      "      14  10  5" "PK7" 14 14 1 2 25  102301  0 1 1
      "      14  13  4" "PK7" 14 14 0 . 70   99828  4 1 1
      "      14  18  2" "PK7" 14 14 0 . 41   31942  5 1 1
      "      14  27  4" "PK7" 14 14 0 . 66  113713  4 1 1
      "      15  15 14" "PK7" 15 15 0 . 69  237270  1 1 1
      "      15  24  5" "PK7" 15 15 0 . 45  -11372  7 0 1
      "      15  27  7" "PK7" 15 15 0 . 61  -49907  1 0 1
      "      16   4 10" "PK7" 16 16 0 . 65   87620  2 0 1
      "      16  13  2" "PK7" 16 16 0 . 45   65518  8 1 1
      "      16  13  4" "PK7" 16 16 0 . 45   65518  2 1 1
      "      16  21  4" "PK7" 16 16 1 5 71  -10431  2 1 1
      "      17   4  9" "PK7" 17 17 2 4 68  147479  2 0 1
      "      22  13  2" "PK7" 22 22 0 . 38  -50157  7 1 1
      "      22  15  2" "PK7" 22 22 2 2 41  -45784  5 1 1
      "      22  18  4" "PK7" 22 22 0 . 86  -43064  5 0 1
      "      22  27  5" "PK7" 22 22 1 5 52  -57544  0 1 1
      "      23   1  4" "PK7" 23 23 3 4 54   41852  2 0 1
      "      23  10  6" "PK7" 23 23 0 . 60  114093  1 0 2
      "      23  13  4" "PK7" 23 23 1 5 61  113540  5 1 1
      "      23  18  2" "PK7" 23 23 1 5 37  -30581  0 0 2
      "      23  21  2" "PK7" 23 23 1 5 33  -17752  3 1 2
      "      23  24  3" "PK7" 23 23 1 3 44     848  0 1 1
      "      23  27  2" "PK7" 23 23 0 . 43  -88013  6 1 1
      "      24   4  3" "PK7" 24 24 3 2 62   78872  3 0 1
      "      24   7  2" "PK7" 24 24 0 . 49  -88737 10 0 1
      "      24  10  2" "PK7" 24 24 3 2 47   27966  8 1 1
      "      24  24  2" "PK7" 24 24 1 5 43   53459  4 0 1
      "      25   1  2" "PK7" 25 25 0 . 43  132134  7 1 1
      "      25   7  2" "PK7" 25 25 0 . 39   27010  7 0 1
      "      25  10 11" "PK7" 25 25 0 . 35  -25708  1 0 2
      "      25  15  3" "PK7" 25 25 0 . 58   36745  2 0 1
      "      25  18  2" "PK7" 25 25 0 . 44  -99953 11 0 1
      end
      label values w_highest_edu V106
      label def V106 0 "no education", modify
      label def V106 1 "primary", modify
      label def V106 2 "secondary", modify
      label def V106 3 "higher", modify
      label values w_highest_edu_year V107
      label values age_of_household_head MV152
      label values consanguinity S708A
      label def S708A 0 "no", modify
      label def S708A 1 "yes", modify
      label values m_unions MV503
      label def MV503 1 "once", modify
      label def MV503 2 "more than once", modify
      ------------------ copy up to and including the previous line ------------------

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

      .

      Comment


      • #4
        Behar,

        Have you tried my code in #2? Also, there is no bord variable in the BR data in your data example in #3.

        Comment


        • #5
          Yes, thankfully your code worked but now i require further assistance so i am providing my datasets again
          use "D:\New folder (3)\code\dta\coreside region rival spousal difference work.dta"

          . dataex caseid v000 v001 v002 v003 mv034_1 mv034_2 mv034_3 mv034_4 mv503 mv502 v503
          > v502

          ----------------------- copy starting from the next line -----------------------
          Code:
          * Example generated by -dataex-. For more info, type help dataex
          clear
          input str15 caseid str3 v000 int v001 byte(v002 v003 mv034_1 mv034_2 mv034_3 mv034_4 mv503 mv502 v503 v502)
          "       1   1  2" "PK7"  1  1  2  2 . . . 1 1 1 1
          "       1  21  4" "PK7"  1 21  4  4 . . . 1 1 1 1
          "       2   1  2" "PK7"  2  1  2  2 . . . 1 1 1 1
          "       2   4  2" "PK7"  2  4  2  2 . . . 1 1 1 1
          "       2  21  2" "PK7"  2 21  2  2 . . . 1 1 1 1
          "       2  24  2" "PK7"  2 24  2  2 . . . 1 1 1 1
          "       3   7  2" "PK7"  3  7  2  2 . . . 1 1 1 1
          "       3  18  2" "PK7"  3 18  2  2 . . . 1 1 1 1
          "       3  21  2" "PK7"  3 21  2  2 . . . 1 1 1 1
          "       3  24  4" "PK7"  3 24  4  4 . . . 1 1 1 1
          "       3  27  4" "PK7"  3 27  4  4 . . . 1 1 1 1
          "       4   1  2" "PK7"  4  1  2  2 . . . 1 1 1 1
          "       4   4  2" "PK7"  4  4  2  2 . . . 1 1 1 1
          "       4   7  2" "PK7"  4  7  2  2 . . . 1 1 1 1
          "       4  10  2" "PK7"  4 10  2  2 . . . 1 1 1 1
          "       4  24  2" "PK7"  4 24  2  2 . . . 1 1 1 1
          "       4  27  2" "PK7"  4 27  2  2 . . . 1 1 1 1
          "       5  10  2" "PK7"  5 10  2  2 . . . 1 1 1 1
          "       5  15  2" "PK7"  5 15  2  2 . . . 1 1 1 1
          "       5  21  2" "PK7"  5 21  2  2 . . . 1 1 1 1
          "       6   4  2" "PK7"  6  4  2  2 . . . 1 1 1 1
          "       6   7  4" "PK7"  6  7  4  4 . . . 1 1 1 1
          "       6  18  2" "PK7"  6 18  2  2 . . . 1 1 1 1
          "       6  21  4" "PK7"  6 21  4  4 . . . 1 1 1 1
          "       7   1  3" "PK7"  7  1  3  3 . . . 1 1 1 1
          "       7   4  3" "PK7"  7  4  3  3 . . . 1 1 1 1
          "       7   4 10" "PK7"  7  4 10 10 . . . 1 1 1 1
          "       7  10  2" "PK7"  7 10  2  2 . . . 1 1 1 1
          "       7  18  2" "PK7"  7 18  2  2 . . . 1 1 1 1
          "       7  27  2" "PK7"  7 27  2  2 . . . 1 1 1 1
          "       8   1  2" "PK7"  8  1  2  2 . . . 1 1 1 1
          "       8   4  3" "PK7"  8  4  3  3 . . . 1 1 1 1
          "       8  10  2" "PK7"  8 10  2  2 . . . 1 1 1 1
          "       8  13  4" "PK7"  8 13  4  4 . . . 1 1 1 1
          "       8  15  8" "PK7"  8 15  8  8 . . . 1 1 1 1
          "       9  10  2" "PK7"  9 10  2  2 . . . 1 1 1 1
          "       9  21  4" "PK7"  9 21  4  4 . . . 1 1 1 1
          "      10   7  2" "PK7" 10  7  2  2 . . . 1 1 1 1
          "      10  10  2" "PK7" 10 10  2  2 . . . 1 1 1 1
          "      10  24  9" "PK7" 10 24  9  9 . . . 1 1 1 1
          "      11   4  2" "PK7" 11  4  2  2 . . . 1 1 1 1
          "      11   7  2" "PK7" 11  7  2  2 . . . 1 1 1 1
          "      11  15  3" "PK7" 11 15  3  3 . . . 1 1 1 1
          "      11  21  2" "PK7" 11 21  2  2 . . . 1 1 1 1
          "      11  24  4" "PK7" 11 24  4  4 . . . 1 1 1 1
          "      11  24 10" "PK7" 11 24 10 10 . . . 1 1 1 1
          "      12  10  3" "PK7" 12 10  3  3 . . . 1 1 1 1
          "      12  15  4" "PK7" 12 15  4  4 . . . 1 1 1 1
          "      12  21  2" "PK7" 12 21  2  2 . . . 1 1 1 1
          "      13   4  8" "PK7" 13  4  8  8 . . . 1 1 1 1
          "      13  15  2" "PK7" 13 15  2  2 . . . 1 1 1 1
          "      13  18  4" "PK7" 13 18  4  4 . . . 1 1 1 1
          "      13  24  2" "PK7" 13 24  2  2 . . . 1 1 1 1
          "      14  10  2" "PK7" 14 10  2  2 . . . 1 1 1 1
          "      14  13  4" "PK7" 14 13  4  4 . . . 1 1 1 1
          "      14  18  2" "PK7" 14 18  2  2 . . . 1 1 1 1
          "      14  27  4" "PK7" 14 27  4  4 . . . 1 1 1 1
          "      15  15 14" "PK7" 15 15 14 14 . . . 1 1 1 1
          "      15  24  5" "PK7" 15 24  5  5 . . . 1 1 1 1
          "      15  27  7" "PK7" 15 27  7  7 . . . 1 1 1 1
          "      16   4 10" "PK7" 16  4 10 10 . . . 1 1 1 1
          "      16  13  2" "PK7" 16 13  2  2 . . . 1 1 1 1
          "      16  13  4" "PK7" 16 13  4  4 . . . 1 1 1 1
          "      16  21  4" "PK7" 16 21  4  4 . . . 1 1 1 1
          "      17   4  9" "PK7" 17  4  9  9 . . . 1 1 1 1
          "      22  13  2" "PK7" 22 13  2  2 . . . 1 1 1 1
          "      22  15  2" "PK7" 22 15  2  2 . . . 1 1 1 1
          "      22  18  4" "PK7" 22 18  4  4 . . . 1 1 1 1
          "      23   1  4" "PK7" 23  1  4  4 . . . 1 1 1 1
          "      23  10  6" "PK7" 23 10  6  6 . . . 2 1 1 1
          "      23  13  4" "PK7" 23 13  4  4 . . . 1 1 1 1
          "      23  21  2" "PK7" 23 21  2  2 . . . 2 1 1 1
          "      23  27  2" "PK7" 23 27  2  2 . . . 1 1 1 1
          "      24   4  3" "PK7" 24  4  3  3 . . . 1 1 1 1
          "      24   7  2" "PK7" 24  7  2  2 . . . 1 1 1 1
          "      24  10  2" "PK7" 24 10  2  2 . . . 1 1 1 1
          "      24  24  2" "PK7" 24 24  2  2 . . . 1 1 1 1
          "      25   1  2" "PK7" 25  1  2  2 . . . 1 1 1 1
          "      25   7  2" "PK7" 25  7  2  2 . . . 1 1 1 1
          "      25  10 11" "PK7" 25 10 11 11 . . . 2 1 1 1
          "      25  15  3" "PK7" 25 15  3  3 . . . 1 1 1 1
          "      25  18  2" "PK7" 25 18  2  2 . . . 1 1 1 1
          "      25  21  4" "PK7" 25 21  4  4 . . . 1 1 1 1
          "      25  24  2" "PK7" 25 24  2  2 . . . 2 1 1 1
          "      25  27  4" "PK7" 25 27  4  4 . . . 1 1 1 1
          "      26   4  2" "PK7" 26  4  2  2 . . . 1 1 1 1
          "      26   7  2" "PK7" 26  7  2  2 . . . 1 1 1 1
          "      26  21  2" "PK7" 26 21  2  2 . . . 2 1 1 1
          "      27   1  2" "PK7" 27  1  2  2 . . . 1 1 1 1
          "      27   7  2" "PK7" 27  7  2  2 . . . 1 1 1 1
          "      27  27  2" "PK7" 27 27  2  2 . . . 1 1 1 1
          "      28   1  2" "PK7" 28  1  2  2 . . . 1 1 1 1
          "      28   7  2" "PK7" 28  7  2  2 . . . 1 1 1 1
          "      28  13  2" "PK7" 28 13  2  2 . . . 1 1 1 1
          "      28  24  2" "PK7" 28 24  2  2 . . . 1 1 1 1
          "      29  15  4" "PK7" 29 15  4  4 . . . 1 1 1 1
          "      30   1  4" "PK7" 30  1  4  4 . . . 1 1 1 1
          "      30   7  2" "PK7" 30  7  2  2 . . . 1 1 1 1
          "      30   7  8" "PK7" 30  7  8  8 . . . 1 1 1 1
          "      30  27  2" "PK7" 30 27  2  2 . . . 1 1 1 1
          end
          label values mv034_1 MV034_1
          label values mv034_2 MV034_2
          label values mv034_3 MV034_3
          label values mv034_4 MV034_4
          label values mv503 MV503
          label def MV503 1 "once", modify
          label def MV503 2 "more than once", modify
          label values mv502 MV502
          label def MV502 1 "currently in union/living with a woman", modify
          label values v503 V503
          label def V503 1 "once", modify
          label values v502 V502
          label def V502 1 "currently in union/living with a man", modify
          ------------------ copy up to and including the previous line ------------------

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

          . des caseid v000 v001 v002 v003 mv034_1 mv034_2 mv034_3 mv034_4 mv503 mv502 v503 v5
          > 02

          Variable Storage Display Value
          name type format label Variable label
          ------------------------------------------------------------------------------------
          caseid str15 %15s case identification
          v000 str3 %3s country code and phase
          v001 int %8.0g cluster number
          v002 byte %8.0g household number
          v003 byte %8.0g respondent's line number
          mv034_1 byte %8.0g MV034_1 line number of wife/partner
          mv034_2 byte %8.0g MV034_2 line number of wife/partner
          mv034_3 byte %8.0g MV034_3 line number of wife/partner
          mv034_4 byte %8.0g MV034_4 line number of wife/partner
          mv503 byte %8.0g MV503 number of unions
          mv502 byte %8.0g MV502 currently/formerly/never in union
          v503 byte %8.0g V503 number of unions
          v502 byte %8.0g V502 currently/formerly/never in union

          .
          use "D:\New folder (3)\code\do\duration_n and failure_n.dta"



          . dataex caseid v000 v001 v002 v003 v004 v005 v201 bord

          ----------------------- copy starting from the next line -----------------------
          Code:
          * Example generated by -dataex-. For more info, type help dataex
          clear
          input str15 caseid str3 v000 int v001 byte(v002 v003) int v004 long v005 byte(v201 bord)
          "       1   1  2" "PK7" 1  1 2 1 868683 5 5
          "       1   1  2" "PK7" 1  1 2 1 868683 5 4
          "       1   1  2" "PK7" 1  1 2 1 868683 5 3
          "       1   1  2" "PK7" 1  1 2 1 868683 5 2
          "       1   1  2" "PK7" 1  1 2 1 868683 5 1
          "       1   4  1" "PK7" 1  4 1 1 868683 5 5
          "       1   4  1" "PK7" 1  4 1 1 868683 5 4
          "       1   4  1" "PK7" 1  4 1 1 868683 5 3
          "       1   4  1" "PK7" 1  4 1 1 868683 5 2
          "       1   4  1" "PK7" 1  4 1 1 868683 5 1
          "       1   5  2" "PK7" 1  5 2 1 868683 5 5
          "       1   5  2" "PK7" 1  5 2 1 868683 5 4
          "       1   5  2" "PK7" 1  5 2 1 868683 5 3
          "       1   5  2" "PK7" 1  5 2 1 868683 5 2
          "       1   5  2" "PK7" 1  5 2 1 868683 5 1
          "       1   6  2" "PK7" 1  6 2 1 868683 4 4
          "       1   6  2" "PK7" 1  6 2 1 868683 4 3
          "       1   6  2" "PK7" 1  6 2 1 868683 4 2
          "       1   6  2" "PK7" 1  6 2 1 868683 4 1
          "       1   8  4" "PK7" 1  8 4 1 868683 1 1
          "       1   8  7" "PK7" 1  8 7 1 868683 1 1
          "       1   9  4" "PK7" 1  9 4 1 868683 4 4
          "       1   9  4" "PK7" 1  9 4 1 868683 4 3
          "       1   9  4" "PK7" 1  9 4 1 868683 4 2
          "       1   9  4" "PK7" 1  9 4 1 868683 4 1
          "       1  10  2" "PK7" 1 10 2 1 868683 5 5
          "       1  10  2" "PK7" 1 10 2 1 868683 5 4
          "       1  10  2" "PK7" 1 10 2 1 868683 5 3
          "       1  10  2" "PK7" 1 10 2 1 868683 5 2
          "       1  10  2" "PK7" 1 10 2 1 868683 5 1
          "       1  10  7" "PK7" 1 10 7 1 868683 2 2
          "       1  10  7" "PK7" 1 10 7 1 868683 2 1
          "       1  11  1" "PK7" 1 11 1 1 868683 6 6
          "       1  11  1" "PK7" 1 11 1 1 868683 6 5
          "       1  11  1" "PK7" 1 11 1 1 868683 6 4
          "       1  11  1" "PK7" 1 11 1 1 868683 6 3
          "       1  11  1" "PK7" 1 11 1 1 868683 6 2
          "       1  11  1" "PK7" 1 11 1 1 868683 6 1
          "       1  12  2" "PK7" 1 12 2 1 868683 2 2
          "       1  12  2" "PK7" 1 12 2 1 868683 2 1
          "       1  14  2" "PK7" 1 14 2 1 868683 4 4
          "       1  14  2" "PK7" 1 14 2 1 868683 4 3
          "       1  14  2" "PK7" 1 14 2 1 868683 4 2
          "       1  14  2" "PK7" 1 14 2 1 868683 4 1
          "       1  15  2" "PK7" 1 15 2 1 868683 5 5
          "       1  15  2" "PK7" 1 15 2 1 868683 5 4
          "       1  15  2" "PK7" 1 15 2 1 868683 5 3
          "       1  15  2" "PK7" 1 15 2 1 868683 5 2
          "       1  15  2" "PK7" 1 15 2 1 868683 5 1
          "       1  19  2" "PK7" 1 19 2 1 868683 6 6
          "       1  19  2" "PK7" 1 19 2 1 868683 6 5
          "       1  19  2" "PK7" 1 19 2 1 868683 6 4
          "       1  19  2" "PK7" 1 19 2 1 868683 6 3
          "       1  19  2" "PK7" 1 19 2 1 868683 6 2
          "       1  19  2" "PK7" 1 19 2 1 868683 6 1
          "       1  20  4" "PK7" 1 20 4 1 868683 5 5
          "       1  20  4" "PK7" 1 20 4 1 868683 5 4
          "       1  20  4" "PK7" 1 20 4 1 868683 5 3
          "       1  20  4" "PK7" 1 20 4 1 868683 5 2
          "       1  20  4" "PK7" 1 20 4 1 868683 5 1
          "       1  21  4" "PK7" 1 21 4 1 868683 2 2
          "       1  21  4" "PK7" 1 21 4 1 868683 2 1
          "       1  22  1" "PK7" 1 22 1 1 868683 4 4
          "       1  22  1" "PK7" 1 22 1 1 868683 4 3
          "       1  22  1" "PK7" 1 22 1 1 868683 4 2
          "       1  22  1" "PK7" 1 22 1 1 868683 4 1
          "       1  23  2" "PK7" 1 23 2 1 868683 5 5
          "       1  23  2" "PK7" 1 23 2 1 868683 5 4
          "       1  23  2" "PK7" 1 23 2 1 868683 5 3
          "       1  23  2" "PK7" 1 23 2 1 868683 5 2
          "       1  23  2" "PK7" 1 23 2 1 868683 5 1
          "       1  24  2" "PK7" 1 24 2 1 868683 6 6
          "       1  24  2" "PK7" 1 24 2 1 868683 6 5
          "       1  24  2" "PK7" 1 24 2 1 868683 6 4
          "       1  24  2" "PK7" 1 24 2 1 868683 6 3
          "       1  24  2" "PK7" 1 24 2 1 868683 6 2
          "       1  24  2" "PK7" 1 24 2 1 868683 6 1
          "       1  24  3" "PK7" 1 24 3 1 868683 1 1
          "       1  25  2" "PK7" 1 25 2 1 868683 3 3
          "       1  25  2" "PK7" 1 25 2 1 868683 3 2
          "       1  25  2" "PK7" 1 25 2 1 868683 3 1
          "       1  27  2" "PK7" 1 27 2 1 868683 2 2
          "       1  27  2" "PK7" 1 27 2 1 868683 2 1
          "       1  27  5" "PK7" 1 27 5 1 868683 1 1
          "       1  28  2" "PK7" 1 28 2 1 868683 3 3
          "       1  28  2" "PK7" 1 28 2 1 868683 3 2
          "       1  28  2" "PK7" 1 28 2 1 868683 3 1
          "       2   1  2" "PK7" 2  1 2 2  75017 5 5
          "       2   1  2" "PK7" 2  1 2 2  75017 5 4
          "       2   1  2" "PK7" 2  1 2 2  75017 5 3
          "       2   1  2" "PK7" 2  1 2 2  75017 5 2
          "       2   1  2" "PK7" 2  1 2 2  75017 5 1
          "       2   3  2" "PK7" 2  3 2 2  75017 1 1
          "       2   4  2" "PK7" 2  4 2 2  75017 3 3
          "       2   4  2" "PK7" 2  4 2 2  75017 3 2
          "       2   4  2" "PK7" 2  4 2 2  75017 3 1
          "       2   6  2" "PK7" 2  6 2 2  75017 3 3
          "       2   6  2" "PK7" 2  6 2 2  75017 3 2
          "       2   6  2" "PK7" 2  6 2 2  75017 3 1
          "       2   8  2" "PK7" 2  8 2 2  75017 4 4
          end
          ------------------ copy up to and including the previous line ------------------

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

          . des caseid v000 v001 v002 v003 v004 v005 v201 bord

          Variable Storage Display Value
          name type format label Variable label
          ------------------------------------------------------------------------------------
          caseid str15 %15s case identification
          v000 str3 %3s country code and phase
          v001 int %8.0g cluster number
          v002 byte %8.0g household number
          v003 byte %8.0g respondent's line number
          v004 int %8.0g ultimate area unit
          v005 long %12.0g women's individual sample weight (6
          decimals)
          v201 byte %8.0g total children ever born
          bord byte %8.0g birth order number

          Comment


          • #6
            Behar,

            If you have tried to use the following code, you will notice that your inquiries in #3 are solved
            Code:
            use "BR", clear
            merge m:1 caseid using`CR'
            Code:
            . list caseid bord v201 v502 mv503 in 1/10
            
                 +------------------------------------------------------------------------------+
                 |          caseid   bord   v201                                   v502   mv503 |
                 |------------------------------------------------------------------------------|
              1. |        1   1  2      5      5   currently in union/living with a man    once |
              2. |        1   1  2      4      5   currently in union/living with a man    once |
              3. |        1   1  2      3      5   currently in union/living with a man    once |
              4. |        1   1  2      2      5   currently in union/living with a man    once |
              5. |        1   1  2      1      5   currently in union/living with a man    once |
                 |------------------------------------------------------------------------------|
              6. |        1   4  1      5      5                                      .       . |
              7. |        1   4  1      4      5                                      .       . |
              8. |        1   4  1      3      5                                      .       . |
              9. |        1   4  1      2      5                                      .       . |
             10. |        1   4  1      1      5                                      .       . |
                 +------------------------------------------------------------------------------+
            3. Be able to identify whether the couple lives in a monogamous or polygamous setup after the merge.
            This information is displayed by variable mv503

            Comment


            • #7
              thankyou for your guidance

              Comment

              Working...
              X