Announcement

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

  • Household and Fertility

    👋 Hello to everyone ,
    I am trying to do a research using Ess dataset, I need to create a variable that can represent fertility. Is there any possibility to create a variable that takes into account the number of children per household from the household composition?
    rshipa2 rshipa3 rshipa4 rshipa5 rshipa6 rshipa7 rshipa8
    Pare Pare Brot Brot Brot Not Not
    Pare Pare Brot Not Not Not Not
    Husb Not Not Not Not Not Not
    Not Not Not Not Not Not Not
    Not Not Not Not Not Not Not
    Husb Son/ Son/ Son/ Not Not Not
    Not Not Not Not Not Not Not
    Husb Son/ Not Not Not Not Not
    Pare Not Not Not Not Not Not
    Husb Not Not Not Not Not Not
    Not Not Not Not Not Not Not
    Husb Not Not Not Not Not Not
    Pare Pare Brot Brot Not Not Not
    Not Not Not Not Not Not Not
    Pare Pare Brot Brot Not Not Not
    Pare Pare Brot Brot Don' Not Not
    Husb Not Not Not Not Not Not
    Husb Son/ Son/ Not Not Not Not
    Pare Pare Husb Not Not Not Not
    Pare Pare Brot Othe Not Not Not
    Husb Son/ Not Not Not Not Not

    Can anyone help me with the commands?

  • #2
    Eli:
    welcome to this forum.
    Please, take a look at the FAQ on how to post more effectively. Thanks.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Your data need some explanation. I assume here that each observation represents a different household. I also imagine that there is a household id variable in your full data set, but as you don't provide one in the example, I create one in the code below--you can skip that step and use the real household id variable instead. I'm guessing also that "Pare" abbreviates parent, and "Brot" abbreviates brother, so that these, like "Not" which abbreviates "no such person", do not count as children. I assume that "Son/"'s are children. I am gobsmacked that nobody appears to have any daughters! You will have to modify the code to include them, as, in the absence of any examples, I don't know how those are represented in the data set.

      I also don't see how you can estimate fertility from this data. This code shows you how to calculate the total number of children in the household (well, the total number of sons). But as there is no information about the mothers' pre/post-menopausal status, calculating fertility is out of the question.

      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input str4(rshipa2 rshipa3 rshipa4 rshipa5 rshipa6) str3(rshipa7 rshipa8)
      "Pare" "Pare" "Brot" "Brot" "Brot" "Not" "Not"
      "Pare" "Pare" "Brot" "Not"  "Not"  "Not" "Not"
      "Husb" "Not"  "Not"  "Not"  "Not"  "Not" "Not"
      "Not"  "Not"  "Not"  "Not"  "Not"  "Not" "Not"
      "Not"  "Not"  "Not"  "Not"  "Not"  "Not" "Not"
      "Husb" "Son/" "Son/" "Son/" "Not"  "Not" "Not"
      "Not"  "Not"  "Not"  "Not"  "Not"  "Not" "Not"
      "Husb" "Son/" "Not"  "Not"  "Not"  "Not" "Not"
      "Pare" "Not"  "Not"  "Not"  "Not"  "Not" "Not"
      "Husb" "Not"  "Not"  "Not"  "Not"  "Not" "Not"
      "Not"  "Not"  "Not"  "Not"  "Not"  "Not" "Not"
      "Husb" "Not"  "Not"  "Not"  "Not"  "Not" "Not"
      "Pare" "Pare" "Brot" "Brot" "Not"  "Not" "Not"
      "Not"  "Not"  "Not"  "Not"  "Not"  "Not" "Not"
      "Pare" "Pare" "Brot" "Brot" "Not"  "Not" "Not"
      "Pare" "Pare" "Brot" "Brot" "Don'" "Not" "Not"
      "Husb" "Not"  "Not"  "Not"  "Not"  "Not" "Not"
      "Husb" "Son/" "Son/" "Not"  "Not"  "Not" "Not"
      "Pare" "Pare" "Husb" "Not"  "Not"  "Not" "Not"
      "Pare" "Pare" "Brot" "Othe" "Not"  "Not" "Not"
      "Husb" "Son/" "Not"  "Not"  "Not"  "Not" "Not"
      end
      
      gen `c(obs_t)' hhid = _n
      reshape long rshipa, i(hhid)
      by hhid (_j), sort: egen n_children = total(rshipa == "Son/") // MODIFY THIS TO INCLUDE DAUGHTERS, TOO.
      reshape wide
      In the future, when showing data examples, please use the -dataex- command to do so, as I have here. 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.

      Also in the future, please spell out abbreviations like Ess. I imagine you are referring to the European Social Survey. But this is an international, multidisciplinary community. I suspect that many, perhaps most, Forum members have no idea what Ess is. When posting here, for clarity, the only common knowledge you should assume is a bit of statistics, a bit of Stata, and anything that any university educated person anywhere in the world would know.

      Added: Crossed with #2, which I agree with.

      Comment

      Working...
      X