Hi everyone,
I have a household level data where parents give information on themselves and their children. I would like to turn this data into children level data. However, I have not a lot of clue about how to do it. I appreciate if someone can help me with this.
Below, you can see 3 variables I got from the data. I have mergeid (id of parents), w7_ch_gender1 (gender of children), and w7_ch_number (number of children that parents have). So first, I would like to create a unique id number for each children and then I would like to transpose the data in a way that it will be at children level. parents id will be repeated depending on how many children they have. I am not sure if i am clear but i will demonstrate what I exactly want in the second example:
mergeid w7_ch_gender1 w7_ch_number
AT-014640-01 Male 2
AT-014640-02 Male 2
AT-015615-01 Female 2
AT-015935-01 Female 1
AT-017298-01 Female 2
AT-017821-02 Female 3
Example of what I would like to achieve:
So mergeid is doubled if both parents answered the questions so is the number of children (row-wise). There is a unique id number for each child.
mergeid number of children childid gender
AT-000674-01 2 19701 female
AT-000674-01 2 19731 female
AT-001492-02 6 19702 male
AT-001492-01 6 19702 male
AT-001492-02 6 19732 female
AT-001492-01 6 19732 female
AT-001492-01 6 19742 male
AT-001492-02 6 19742 male
AT-001492-01 6 19801 female
AT-001492-02 6 19801 female
AT-001492-01 6 19822 male
AT-001492-02 6 19822 male
AT-001492-02 6 19831 male
AT-001492-01 6 19831 male
Can someone help me with the coding? Thanks in advance!
Related Posts with how to turn household level data into individual level data
(possibly) simple bar graph comparing two variables (not one variable over the other)Hello, I've spent hours since yesterday to plot a simple bar chart which displays two variables wi…
Storing and appending marginal effects for successive mlogit models in a single matrixDear members of the list, I am running a multinomial logit regression for each one of a series of c…
Multiplication errors using genI'm using the code below to generate a new variable that is the unique id multiplies by 100. However…
Exporting table to excelestimates table pre_crisis pre_crisis1 pre_crisis2 crisis crisis1 crisis2 post_crisis post_crisis1 p…
Heckman CorrectionDear All: I use logistic regression analysis to model the likelihood that a drug-development projec…
Subscribe to:
Post Comments (Atom)
0 Response to how to turn household level data into individual level data
Post a Comment