Announcement

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

  • Ranking Birth Order of Alive Children in DHS Dataset

    Dear Forum Members,

    I am working with the DHS 2017-18 Pakistan dataset, which includes variables (b5_01 to b5_20) indicating whether children are alive within a household. These variables are arranged in descending order of birth, with bord_01 representing the oldest child and bord_20 the youngest child, where applicable.

    My goal is to:
    1. Filter for Alive Children: Keep only the observations where at least one child is alive, based on non-missing values in b5_01 to b5_20.
    2. Rank Children by Birth Order: For each household, rank the children based on their birth order from bord_01 to bord_20, starting with the oldest child.
    Could anyone provide guidance on how to implement this ranking method in Stata, ensuring the correct birth order is assigned within each household?

  • #2
    I'm having considerable difficulty imagining what this data looks like. If variables bord_01 to bord_20 rank the children based on birth order, then it seems that we must always have bord_01 = 1, bord_02 = 2, ..., bord_20 = 20, or perhaps deviating from that only in having missing values for bord_# where # is greater than the number of children. In otherwords, the bord_* variables as you describe them seem redundant at best, and possibly altogether pointless.

    So it would really be helpful if you post example data. As the data set contains a very large number of variables, more than can readily be posted here, I suggest you post just the household id variable, b5_01 through b5_10, and bord_01 through bord_10. To post the example data in a way that will enable those who want to help you to use it, not just look at it, you should use the -dataex- command. If you are running version 18, 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.

    In general, when asking for help with code, it is a good idea to show example data. While there are some problems that are so simple and so clearly stated that no example data is needed, that is the exception not the rule. And it never hurts to show it--it only takes a few seconds.

    Added: It would also be good to clarify what you mean by "ensuring the correct birth order is assigned within each household." By your description, the bord_* variables already do this. Perhaps you mean that if the third-born child is deceased, then the ranks of the fourth and fifth born children should be "promoted" to 3 and 4, respectively?
    Last edited by Clyde Schechter; 06 Nov 2024, 10:19.

    Comment


    • #3
      I am working with data on married women aged 13 to 39 years who have living children. My goal is to identify the eldest living child within each household and ensure that birth order ranks are reassigned only to those children who are currently alive for that i am using the variable bord_01 to bord_20 respectively. it is arranged in descending order. For example, if a household originally has five children and the birth order number 5 (bord_05) is the eldest living child, they should be marked as the first-born in the new birth order. The birth order number 4 (bord_04) would then be marked as the second-born, and so on. This approach will effectively "promote" the ranks of living children to fill any gaps left by deceased siblings, maintaining a continuous birth order. rephrase


      ----------------------- copy starting from the next line -----------------------
      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input str15 caseid byte(v002 b5_01 b5_02 b5_03 b5_04 b5_05 b5_06 b5_07 b5_08 b5_09 b5_10 bord_01 bord_02 bord_03 bord_04 bord_05 bord_06 bord_07 bord_08 bord_09 bord_10)
      "       1   1  2"  1 1 1 1 1 1 . . . . . 5 4 3 2 1 . . . . .
      "       1   4  1"  4 1 1 1 1 1 . . . . . 5 4 3 2 1 . . . . .
      "       1   5  2"  5 1 1 1 1 1 . . . . . 5 4 3 2 1 . . . . .
      "       1   6  2"  6 1 1 1 1 . . . . . . 4 3 2 1 . . . . . .
      "       1   7  2"  7 . . . . . . . . . . . . . . . . . . . .
      "       1   8  4"  8 0 . . . . . . . . . 1 . . . . . . . . .
      "       1   8  7"  8 1 . . . . . . . . . 1 . . . . . . . . .
      "       1   9  4"  9 1 1 1 1 . . . . . . 4 3 2 1 . . . . . .
      "       1  10  2" 10 1 1 1 1 1 . . . . . 5 4 3 2 1 . . . . .
      "       1  10  7" 10 1 1 . . . . . . . . 2 1 . . . . . . . .
      "       1  11  1" 11 1 1 1 1 1 1 . . . . 6 5 4 3 2 1 . . . .
      "       1  12  2" 12 1 1 . . . . . . . . 2 1 . . . . . . . .
      "       1  14  2" 14 1 1 1 1 . . . . . . 4 3 2 1 . . . . . .
      "       1  15  2" 15 1 1 1 1 1 . . . . . 5 4 3 2 1 . . . . .
      "       1  19  2" 19 1 1 1 1 1 1 . . . . 6 5 4 3 2 1 . . . .
      "       1  20  4" 20 1 1 1 1 1 . . . . . 5 4 3 2 1 . . . . .
      "       1  21  4" 21 1 1 . . . . . . . . 2 1 . . . . . . . .
      "       1  22  1" 22 1 1 1 1 . . . . . . 4 3 2 1 . . . . . .
      "       1  23  2" 23 1 1 1 0 1 . . . . . 5 4 3 2 1 . . . . .
      "       1  24  2" 24 1 1 1 1 1 1 . . . . 6 5 4 3 2 1 . . . .
      end
      label values b5_01 B5_01
      label def B5_01 0 "no", modify
      label def B5_01 1 "yes", modify
      label values b5_02 B5_02
      label def B5_02 1 "yes", modify
      label values b5_03 B5_03
      label def B5_03 1 "yes", modify
      label values b5_04 B5_04
      label def B5_04 0 "no", modify
      label def B5_04 1 "yes", modify
      label values b5_05 B5_05
      label def B5_05 1 "yes", modify
      label values b5_06 B5_06
      label def B5_06 1 "yes", modify
      label values b5_07 B5_07
      label values b5_08 B5_08
      label values b5_09 B5_09
      label values b5_10 B5_10
      ------------------ copy up to and including the previous line ------------------

      Listed 20 out of 15068 observations





      Comment


      • #4
        OK. I'm not sure what you want the final results to look like. Here is how I would do it, leaving the data in a form that will probably prove most useful for ongoing data management and analysis.

        Code:
        reshape long b5 bord, i(caseid) j(seq) string
        destring seq, replace ignore("_")
        drop if b5 != 1    // ELIMINATE DECEASED OR NEVER-EXISTING CHILDREN
        
        by caseid (bord), sort: replace bord = _n
        drop b5
        This data set now has one observation per living child. The variable b5 is gone, because only living children are included, so b5 has no information. The variable seq is a number that tells you which variables in the original data correspond to this child. So if seq = 2, the original data for this child came from b5_02 and bord_02. The variable bord now gives the birth orders, with "promotion" of those born subsequent to a child who is now deceased. That is within each household (caseid) the birth orders now start at 1 and increase consecutively.

        There is really no need for a variable to mark the first born; it's just those children with bord == 1.

        Comment


        • #5
          Thank you again for your support. The provided code worked successfully, and I now have an additional question.

          How can I generate two new variables in Stata that would show each child’s gender and age in months within each household, with this information displayed next to each child’s birth order? For instance, if caseid 112 has five children, I would like the gender and age of each child to appear in the same row as their respective birth order.


          ----------------------- copy starting from the next line -----------------------
          Code:
          * Example generated by -dataex-. For more info, type help dataex
          clear
          input str15 caseid byte(seq bord) float(rival coreside eligible birth_order)
          "       1   1  2" 1 5 0 1 1 1
          "       1   1  2" 2 4 0 1 1 2
          "       1   1  2" 3 3 0 1 1 3
          "       1   1  2" 4 2 0 1 1 4
          "       1   1  2" 5 1 0 1 1 5
          "       1   4  1" 1 5 0 0 1 1
          "       1   4  1" 2 4 0 0 1 2
          "       1   4  1" 3 3 0 0 1 3
          "       1   4  1" 4 2 0 0 1 4
          "       1   4  1" 5 1 0 0 1 5
          "       1   5  2" 1 5 0 0 1 1
          "       1   5  2" 2 4 0 0 1 2
          "       1   5  2" 3 3 0 0 1 3
          "       1   5  2" 4 2 0 0 1 4
          "       1   5  2" 5 1 0 0 1 5
          "       1   8  7" 1 1 0 1 1 1
          "       1   9  4" 1 4 0 1 1 1
          "       1   9  4" 2 3 0 1 1 2
          "       1   9  4" 3 2 0 1 1 3
          "       1   9  4" 4 1 0 1 1 4
          "       1  10  2" 1 5 0 1 1 1
          "       1  10  2" 2 4 0 1 1 2
          "       1  10  2" 3 3 0 1 1 3
          "       1  10  2" 4 2 0 1 1 4
          "       1  10  2" 5 1 0 1 1 5
          "       1  10  7" 1 2 1 1 1 1
          "       1  10  7" 2 1 1 1 1 2
          "       1  11  1" 1 6 0 0 1 1
          "       1  11  1" 2 5 0 0 1 2
          "       1  11  1" 3 4 0 0 1 3
          "       1  11  1" 4 3 0 0 1 4
          "       1  11  1" 5 2 0 0 1 5
          "       1  11  1" 6 1 0 0 1 6
          "       1  12  2" 1 2 0 1 1 1
          "       1  12  2" 2 1 0 1 1 2
          "       1  20  4" 1 5 0 1 1 1
          "       1  20  4" 2 4 0 1 1 2
          "       1  20  4" 3 3 0 1 1 3
          "       1  20  4" 4 2 0 1 1 4
          "       1  20  4" 5 1 0 1 1 5
          "       1  21  4" 1 2 0 1 1 1
          "       1  21  4" 2 1 0 1 1 2
          "       1  23  2" 1 4 0 1 1 1
          "       1  23  2" 2 3 0 1 1 2
          "       1  23  2" 3 2 0 1 1 3
          "       1  23  2" 5 1 0 1 1 4
          "       1  24  3" 1 1 0 0 1 1
          "       1  25  2" 1 3 0 1 1 1
          "       1  25  2" 2 2 0 1 1 2
          "       1  25  2" 3 1 0 1 1 3
          "       1  27  2" 1 2 0 0 1 1
          "       1  27  2" 2 1 0 0 1 2
          "       1  27  5" 1 1 0 0 1 1
          "       1  28  2" 1 3 0 1 1 1
          "       1  28  2" 2 2 0 1 1 2
          "       1  28  2" 3 1 0 1 1 3
          "       2   1  2" 1 5 0 1 1 1
          "       2   1  2" 2 4 0 1 1 2
          "       2   1  2" 3 3 0 1 1 3
          "       2   1  2" 4 2 0 1 1 4
          "       2   1  2" 5 1 0 1 1 5
          "       2   3  2" 1 1 0 1 1 1
          "       2   4  2" 1 3 0 1 1 1
          "       2   4  2" 2 2 0 1 1 2
          "       2   4  2" 3 1 0 1 1 3
          "       2   8  2" 1 4 0 1 1 1
          "       2   8  2" 2 3 0 1 1 2
          "       2   8  2" 3 2 0 1 1 3
          "       2   8  2" 4 1 0 1 1 4
          "       2   9  4" 1 3 0 1 1 1
          "       2   9  4" 2 2 0 1 1 2
          "       2   9  4" 3 1 0 1 1 3
          "       2  11  2" 1 3 0 1 1 1
          "       2  11  2" 2 2 0 1 1 2
          "       2  11  2" 3 1 0 1 1 3
          "       2  12  2" 1 1 0 1 1 1
          "       2  13  2" 1 4 0 1 1 1
          "       2  13  2" 2 3 0 1 1 2
          "       2  13  2" 3 2 0 1 1 3
          "       2  13  2" 4 1 0 1 1 4
          "       2  14  2" 1 6 0 1 1 1
          "       2  14  2" 2 5 0 1 1 2
          "       2  14  2" 3 4 0 1 1 3
          "       2  14  2" 4 3 0 1 1 4
          "       2  14  2" 5 2 0 1 1 5
          "       2  14  2" 6 1 0 1 1 6
          "       2  16  3" 1 5 0 0 1 1
          "       2  16  3" 2 4 0 0 1 2
          "       2  16  3" 3 3 0 0 1 3
          "       2  16  3" 4 2 0 0 1 4
          "       2  16  3" 5 1 0 0 1 5
          "       2  17  2" 1 5 0 1 1 1
          "       2  17  2" 2 4 0 1 1 2
          "       2  17  2" 3 3 0 1 1 3
          "       2  17  2" 4 2 0 1 1 4
          "       2  17  2" 5 1 0 1 1 5
          "       2  21  2" 1 2 0 1 1 1
          "       2  21  2" 2 1 0 1 1 2
          "       2  26  2" 1 3 0 1 1 1
          "       2  26  2" 2 2 0 1 1 2
          end
          label values coreside coreside_label
          label def coreside_label 0 "Not Coresident", modify
          label def coreside_label 1 "Coresident", modify
          ------------------ copy up to and including the previous line ------------------

          Listed 100 out of 29149 observations

          Variable Storage Display Value
          name type format label Variable label
          -----------------------------------------------------------------------------------------
          caseid str15 %15s case identification
          bord_01 byte %8.0g birth order number
          bord_02 byte %8.0g birth order number
          bord_03 byte %8.0g birth order number
          bord_04 byte %8.0g birth order number
          bord_05 byte %8.0g birth order number
          bord_06 byte %8.0g birth order number
          bord_07 byte %8.0g birth order number
          bord_08 byte %8.0g birth order number
          bord_09 byte %8.0g birth order number
          bord_10 byte %8.0g birth order number
          b4_01 byte %8.0g B4_01 sex of child
          b4_02 byte %8.0g B4_02 sex of child
          b4_03 byte %8.0g B4_03 sex of child
          b4_04 byte %8.0g B4_04 sex of child
          b4_05 byte %8.0g B4_05 sex of child
          b4_06 byte %8.0g B4_06 sex of child
          b4_07 byte %8.0g B4_07 sex of child
          b4_08 byte %8.0g B4_08 sex of child
          b4_09 byte %8.0g B4_09 sex of child
          b4_10 byte %8.0g B4_10 sex of child
          b4_11 byte %8.0g B4_11 sex of child
          b4_12 byte %8.0g B4_12 sex of child
          b4_13 byte %8.0g B4_13 sex of child
          b4_14 byte %8.0g B4_14 sex of child
          b5_01 byte %8.0g B5_01 child is alive
          b5_02 byte %8.0g B5_02 child is alive
          b5_03 byte %8.0g B5_03 child is alive
          b5_04 byte %8.0g B5_04 child is alive
          b5_05 byte %8.0g B5_05 child is alive
          b5_06 byte %8.0g B5_06 child is alive
          b5_07 byte %8.0g B5_07 child is alive
          b5_08 byte %8.0g B5_08 child is alive
          b5_09 byte %8.0g B5_09 child is alive
          b19_01 int %8.0g current age of child in months (months
          since birth for dead children)
          b19_02 int %8.0g current age of child in months (months
          since birth for dead children)
          b19_03 int %8.0g current age of child in months (months
          since birth for dead children)
          b19_04 int %8.0g current age of child in months (months
          since birth for dead children)
          b19_05 int %8.0g current age of child in months (months
          since birth for dead children)
          b19_06 int %8.0g current age of child in months (months
          since birth for dead children)
          b19_07 int %8.0g current age of child in months (months
          since birth for dead children)
          b19_08 int %8.0g current age of child in months (months
          since birth for dead children)
          b19_09 int %8.0g current age of child in months (months
          since birth for dead children)
          b19_10 int %8.0g current age of child in months (months
          since birth for dead children)
          b19_11 int %8.0g current age of child in months (months
          since birth for dead children)
          b19_12 int %8.0g current age of child in months (months
          since birth for dead children)
          b19_13 int %8.0g current age of child in months (months
          since birth for dead children)
          b19_14 int %8.0g current age of child in months (months
          since birth for dead children)
          -----------------------------------------------------------------------------------------
          Sorted by:
          Note: Dataset has changed since last saved.
          these are the variables that i want to use


          dataex caseid bord_01 bord_02 bord_03 bord_04 bord_05 bord_06 bord_07 b5_01 b5_02 b5_03 b5_0
          > 4 b5_05 b5_06 b5_07 b5_08

          ----------------------- copy starting from the next line -----------------------
          Code:
          * Example generated by -dataex-. For more info, type help dataex
          clear
          input str15 caseid byte(bord_01 bord_02 bord_03 bord_04 bord_05 bord_06 bord_07 b5_01 b5_02 b5_03 b5_04 b5_05 b5_06 b5_07 b5_08)
          "       1   1  2"  5 4 3 2 1 . . 1 1 1 1 1 . . .
          "       1   4  1"  5 4 3 2 1 . . 1 1 1 1 1 . . .
          "       1   5  2"  5 4 3 2 1 . . 1 1 1 1 1 . . .
          "       1   6  2"  4 3 2 1 . . . 1 1 1 1 . . . .
          "       1   7  2"  . . . . . . . . . . . . . . .
          "       1   8  4"  1 . . . . . . 0 . . . . . . .
          "       1   8  7"  1 . . . . . . 1 . . . . . . .
          "       1   9  4"  4 3 2 1 . . . 1 1 1 1 . . . .
          "       1  10  2"  5 4 3 2 1 . . 1 1 1 1 1 . . .
          "       1  10  7"  2 1 . . . . . 1 1 . . . . . .
          "       1  11  1"  6 5 4 3 2 1 . 1 1 1 1 1 1 . .
          "       1  12  2"  2 1 . . . . . 1 1 . . . . . .
          "       1  14  2"  4 3 2 1 . . . 1 1 1 1 . . . .
          "       1  15  2"  5 4 3 2 1 . . 1 1 1 1 1 . . .
          "       1  19  2"  6 5 4 3 2 1 . 1 1 1 1 1 1 . .
          "       1  20  4"  5 4 3 2 1 . . 1 1 1 1 1 . . .
          "       1  21  4"  2 1 . . . . . 1 1 . . . . . .
          "       1  22  1"  4 3 2 1 . . . 1 1 1 1 . . . .
          "       1  23  2"  5 4 3 2 1 . . 1 1 1 0 1 . . .
          "       1  24  2"  6 5 4 3 2 1 . 1 1 1 1 1 1 . .
          "       1  24  3"  1 . . . . . . 1 . . . . . . .
          "       1  25  2"  3 2 1 . . . . 1 1 1 . . . . .
          "       1  27  2"  2 1 . . . . . 1 1 . . . . . .
          "       1  27  5"  1 . . . . . . 1 . . . . . . .
          "       1  28  2"  3 2 1 . . . . 1 1 1 . . . . .
          "       2   1  2"  5 4 3 2 1 . . 1 1 1 1 1 . . .
          "       2   2  5"  . . . . . . . . . . . . . . .
          "       2   3  2"  1 . . . . . . 1 . . . . . . .
          "       2   4  2"  3 2 1 . . . . 1 1 1 . . . . .
          "       2   6  2"  3 2 1 . . . . 1 1 1 . . . . .
          "       2   8  2"  4 3 2 1 . . . 1 1 1 1 . . . .
          "       2   9  4"  3 2 1 . . . . 1 1 1 . . . . .
          "       2  10  2"  4 3 2 1 . . . 1 1 1 1 . . . .
          "       2  11  2"  3 2 1 . . . . 1 1 1 . . . . .
          "       2  12  2"  1 . . . . . . 1 . . . . . . .
          "       2  13  2"  4 3 2 1 . . . 1 1 1 1 . . . .
          "       2  14  2"  6 5 4 3 2 1 . 1 1 1 1 1 1 . .
          "       2  15  2"  4 3 2 1 . . . 1 1 1 1 . . . .
          "       2  16  3"  5 4 3 2 1 . . 1 1 1 1 1 . . .
          "       2  17  2"  5 4 3 2 1 . . 1 1 1 1 1 . . .
          "       2  18  5"  . . . . . . . . . . . . . . .
          "       2  19  2"  5 4 3 2 1 . . 1 1 1 1 1 . . .
          "       2  19  4"  . . . . . . . . . . . . . . .
          "       2  20  2"  4 3 2 1 . . . 1 1 1 1 . . . .
          "       2  21  2"  2 1 . . . . . 1 1 . . . . . .
          "       2  23  1"  4 3 2 1 . . . 0 1 1 0 . . . .
          "       2  24  2"  3 2 1 . . . . 1 1 1 . . . . .
          "       2  26  2"  3 2 1 . . . . 1 1 1 . . . . .
          "       2  27  2"  5 4 3 2 1 . . 1 1 1 1 1 . . .
          "       2  28  4"  1 . . . . . . 1 . . . . . . .
          "       3   2  1"  9 8 7 6 5 4 3 1 1 1 1 1 1 1 1
          "       3   3  2"  . . . . . . . . . . . . . . .
          "       3   4  1"  7 6 5 4 3 2 1 1 1 1 1 1 1 1 .
          "       3   6  1"  8 7 6 5 4 3 2 1 1 1 1 1 1 1 1
          "       3   7  2"  4 3 2 1 . . . 1 1 1 1 . . . .
          "       3   8  2"  5 4 3 2 1 . . 1 1 1 1 1 . . .
          "       3   8  9"  3 2 1 . . . . 1 1 1 . . . . .
          "       3   8 16"  . . . . . . . . . . . . . . .
          "       3   9  2"  5 4 3 2 1 . . 1 1 1 1 1 . . .
          "       3  11  2"  . . . . . . . . . . . . . . .
          "       3  11  3"  2 1 . . . . . 1 1 . . . . . .
          "       3  12  2"  3 2 1 . . . . 1 1 1 . . . . .
          "       3  12  7"  3 2 1 . . . . 1 1 0 . . . . .
          "       3  13  4"  . . . . . . . . . . . . . . .
          "       3  16  4"  5 4 3 2 1 . . 1 1 1 1 1 . . .
          "       3  16 13"  6 5 4 3 2 1 . 1 1 1 1 1 1 . .
          "       3  16 21"  3 2 1 . . . . 1 1 1 . . . . .
          "       3  17  4"  2 1 . . . . . 1 1 . . . . . .
          "       3  18  2"  1 . . . . . . 1 . . . . . . .
          "       3  19  2"  6 5 4 3 2 1 . 1 1 1 1 1 1 . .
          "       3  20  6"  3 2 1 . . . . 1 1 1 . . . . .
          "       3  21  2"  3 2 1 . . . . 1 1 1 . . . . .
          "       3  22  1"  5 4 3 2 1 . . 1 1 1 1 1 . . .
          "       3  23  2"  4 3 2 1 . . . 1 1 1 1 . . . .
          "       3  24  2"  8 7 6 5 4 3 2 1 1 1 1 1 1 1 1
          "       3  24  4"  2 1 . . . . . 1 1 . . . . . .
          "       3  25  2"  8 7 6 5 4 3 2 1 1 1 1 1 1 1 0
          "       3  26  2"  6 5 4 3 2 1 . 1 1 1 1 1 1 . .
          "       3  27  4"  3 2 1 . . . . 1 1 1 . . . . .
          "       3  27  9"  . . . . . . . . . . . . . . .
          "       3  28  2"  3 2 1 . . . . 0 1 1 . . . . .
          "       3  28  5"  5 4 3 2 1 . . 1 1 1 1 1 . . .
          "       4   1  2"  7 6 5 4 3 2 1 1 1 1 1 1 1 1 .
          "       4   2  2" 10 9 8 7 6 5 4 1 1 0 0 1 1 1 1
          "       4   2  5"  . . . . . . . . . . . . . . .
          "       4   3  2"  3 2 1 . . . . 1 1 1 . . . . .
          "       4   3 12"  2 1 . . . . . 1 1 . . . . . .
          "       4   4  2"  5 4 3 2 1 . . 0 1 1 1 1 . . .
          "       4   5  1"  4 3 2 1 . . . 1 1 0 1 . . . .
          "       4   6  8"  1 . . . . . . 1 . . . . . . .
          "       4   7  2"  5 4 3 2 1 . . 1 1 0 1 1 . . .
          "       4   8  4"  1 . . . . . . 1 . . . . . . .
          "       4   9  2"  3 2 1 . . . . 1 1 1 . . . . .
          "       4  10  2"  9 8 7 6 5 4 3 1 1 1 1 1 1 1 1
          "       4  11  5"  . . . . . . . . . . . . . . .
          "       4  12  2"  9 8 7 6 5 4 3 1 1 1 1 1 1 1 1
          "       4  13  2"  6 5 4 3 2 1 . 1 1 1 1 1 1 . .
          "       4  14  2"  4 3 2 1 . . . 1 1 1 1 . . . .
          "       4  15  1"  4 3 2 1 . . . 1 1 1 1 . . . .
          "       4  17  2"  8 7 6 5 4 3 2 1 1 1 1 1 1 0 1
          end
          label values b5_01 B5_01
          label def B5_01 0 "no", modify
          label def B5_01 1 "yes", modify
          label values b5_02 B5_02
          label def B5_02 1 "yes", modify
          label values b5_03 B5_03
          label def B5_03 0 "no", modify
          label def B5_03 1 "yes", modify
          label values b5_04 B5_04
          label def B5_04 0 "no", modify
          label def B5_04 1 "yes", modify
          label values b5_05 B5_05
          label def B5_05 1 "yes", modify
          label values b5_06 B5_06
          label def B5_06 1 "yes", modify
          label values b5_07 B5_07
          label def B5_07 0 "no", modify
          label def B5_07 1 "yes", modify
          label values b5_08 B5_08
          label def B5_08 0 "no", modify
          label def B5_08 1 "yes", modify
          ------------------ copy up to and including the previous line ------------------

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


          Comment


          • #6
            Well, your -datex- example has no variables for age or sex. But the -des- output you show at least gives their variable names. Fortunately, they have names that parallel those of bord and b5. So all you have to do is change the -reshape long- command to:
            Code:
            reshape long b5 bord b4 b19, i(caseid) j(seq) string
            Everything else stays the same.

            Comment

            Working...
            X