Announcement

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

  • using DHS DATA SET

    Hello, I am new to stata, and making use of DHS Data set, b4__01 to b4_20 are the sex for the number of children each respondent have, while b8_01 to b8_20 are the corresponding ages. how do I sort to form a new variable for the sex of children with ages 10 and below?

    below is the commands i did
    *to merge all the children into a single variable b4
    egen b4= concat(b4_01 b4_02 b4_03 b4_04 b4_05 b4_06 b4_07 b4_08.......), punct(,)

    *to merge all the child age into a single variable b8
    egen b8= concat(b8_01 b8_02 b8_03 b8_04 b8_05 b8_06 b8_07 b8_08.....), punct(,)

    but when i run a probit regression I get an error message of no observation.
    thanks

  • #2
    You need to reshape your data. For specific code suggestions, copy and paste the result from the following:

    Code:
    *ssc install dataex
    dataex in 1/10

    Comment


    • #3
      The Question is how do I reshape it? the code you gave above is giving me an error message.

      Comment


      • #4
        The Question is how do I reshape it?
        Code:
        help reshape
        will offer some guidance.

        the code you gave above is giving me an error message.
        You do not give details of the error message. If you do not have dataex, remove the asterisk in the code to install. Otherwise, my guess is that the error relates to too many variables. The problem is that I cannot guess the names of your identifiers (which are key to reshaping) to ask for specific variables. Assuming that these are within the first five variables, run the following after opening your dataset:

        Code:
        qui ds
        local vars
        forval i=1/5{
            local vars `vars' `=word("`r(varlist)'", `i')'
        }
        ssc install dataex
        dataex `vars' b4_01 b4_02 b4_03 b8_01 b8_02 b8_03 in 1/20
        Last edited by Andrew Musau; 16 Jul 2020, 02:47.

        Comment


        • #5
          There are many ‘issues’ described. Perhaps a nice approach would be tackling one at a time. It seems the core knowledge related to data wrangling in Stata is lacking. That said, ‘no observations’ error message may happen when there are strings.
          Best regards,

          Marcos

          Comment


          • #6
            Yes its a 'no observations' error message. I want to have a new variable for respondent having a male child, and another variable for corresponding ages.
            Thank you.

            Comment


            • #7
              Please type - describe - plus the variables included in the probit model.
              Best regards,

              Marcos

              Comment


              • #8
                The variable b4_01 to b4_20 are the variables for 'sex of child' for respondents based on the children positioning at birth, ie. b4_01 is the column for all first born's of each respondents etc. while b8_01 to b8_20 are the columns for the respective 'age of child'. I want to sort theses variables to have var b4 as child being male with var b8 as corresponding ages for ages10 and below if the respondent has a male child ( in other words, as long as a respondent has 1 or more male child between the ages of 0-10, they should be part of this new variables to be generated) . Its after I sort this variables, I intend to run a probit regression. however other variables to be included in the probit would be demographic data as the mothers age, level of education, wealth index, and region. Thank you

                Comment


                • #9
                  What I meant in #7 by "please type describe" (with regard to the probit model's features) was really so, i.e., it wasn't a narrative description of the role of the variables.

                  In short, please type in the Command Window: describe var1 var2 etc .
                  Best regards,

                  Marcos

                  Comment


                  • #10
                    describe b4_01 b4_02 b4_03 b4_04 b8_01 b8_02 b8_03 b8_04

                    storage display value
                    variable name type format label variable label
                    --------------------------------------------------------------------------------------------------------------------------
                    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
                    b8_01 byte %8.0g current age of child
                    b8_02 byte %8.0g current age of child
                    b8_03 byte %8.0g current age of child
                    b8_04 byte %8.0g current age of child

                    Comment


                    • #11
                      describe b4_01 b4_02 b4_03 b4_04 b8_01 b8_02 b8_03 b8_04

                      storage display value
                      variable name type format label variable label
                      --------------------------------------------------------------------------------------------------------------------------
                      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
                      b8_01 byte %8.0g current age of child
                      b8_02 byte %8.0g current age of child
                      b8_03 byte %8.0g current age of child
                      b8_04 byte %8.0g current age of child

                      Comment


                      • #12
                        Well, there aren’t string variables. So far so good. Maybe the issue is related to the data display. The sex of child will probably presente values for each group and missing values when she/he doesn’t take part in the specific group. This will make ‘no observations’ for the model. If this is the case, grouping the variable may solve the issue.
                        Best regards,

                        Marcos

                        Comment

                        Working...
                        X