Announcement

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

  • How can I copy values for a variable to other observations in the same household?

    I want to copy the values for a variable to other missing observations for the same household. Below is a screenshot. The variable I want to adjust is called children (the number of children living in the household). hhid is the household ID. Only women were asked the question in the questionnaire, but I want to assign the same value to the men living in the household.

    Click image for larger version

Name:	children variable.PNG
Views:	1
Size:	66.3 KB
ID:	1414594

  • #2
    FAQ Advice #12 explains that screenshots are usually less help than you imagine. This one is readable

    Code:
    bysort hhid (children) : gen children2 = children[1]
    See alsohttp://www.stata-journal.com/sjpdf.html?articlenum=dm0055

    Comment


    • #3
      Nick, thank you a million times!

      Comment


      • #4
        Hi Nick,

        I have a similar question which has not been resolved yet.
        Below I show data of 3 variables: the interview year (int_year), the year the household moved into the house (hhmove) and if the house has a pool (poolacc; 1=yes, 2= no).

        FYI: the data comes from the American Housing Survey, which interviews the same houses every 2 years.
        For variables of other housing characteristics I have values for all interview years (2001-2011), except for variable 'poolacc'. For this variable, only values in 2011 are available.
        I am trying to impute/copy the same values of poolacc of int_year=2011 to the other interview years as my mentor has instructed me (assuming the houses always had or did not have a pool in the years before).


        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input float int_year int hhmove byte poolacc
        2009 2008 .
        2009 2007 .
        2009 2007 .
        2009 2008 .
        2009 2007 .
        2009 2007 .
        2009 2007 .
        2009 2007 .
        2009 2007 .
        2009 2008 .
        
        end
        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input float int_year int hhmove byte poolacc
        2011 2009 2
        2011 2010 2
        2011 2009 2
        2011 2010 1
        2011 2009 2
        2011 2010 2
        2011 2011 1
        2011 2009 1
        2011 2010 2
        2011 2009 2
        end
        Thanks in advance!

        Comment

        Working...
        X