Re: Creating dummy variable for younger sisters [message #16184 is a reply to message #16157] |
Mon, 19 November 2018 08:52 |
Bridgette-DHS
Messages: 3199 Registered: February 2013
|
Senior Member |
|
|
Following is a response from Senior DHS Stata Specialist, Tom Pullum:
The imputed cmc of birth is given by mm4. You have the cmc of the respondent's birth as v011. In Stata, you can get the numbers of older and younger sisters and brothers with lines such as the following. If you are not using Stata, you will have to convert. I include a check to make sure that the total of these four numbers is equal to the total number of siblings. I arbitrarily count a twin with the older siblings (sisters or brothers).
* Construct copies of mmidx
* older_sister=mmidx if the sibling is female and older than the respondent
* younger_sister=mmidx if the sibling is female and younger than the respondent
* similarly for brothers
OPEN THE IR FILE
rename mm*_0* mm*_*
local li=1
quietly while `li'<=20 {
gen older_sister_`li'=mmidx_`li'
gen younger_sister_`li'=mmidx_`li'
replace older_sister_`li'=. if mm1_`li'==1 | mm4_`li'<v011
replace younger_sister_`li'=. if mm1_`li'==1 | mm4_`li'>=v011
gen older_brother_`li'=mmidx_`li'
gen younger_brother_`li'=mmidx_`li'
replace older_brother_`li'=. if mm1_`li'==2 | mm4_`li'<v011
replace younger_brother_`li'=. if mm1_`li'==2 | mm4_`li'>=v011
local li=`li'+1
}
egen n_siblings=rownonmiss(mmidx*)
egen n_older_sisters=rownonmiss(older_sister*)
egen n_younger_sisters=rownonmiss(younger_sister*)
egen n_older_brothers=rownonmiss(older_brother*)
egen n_younger_brothers=rownonmiss(younger_brother*)
gen n_check=n_older_sisters+n_younger_sisters+n_older_brothers+n_younger_brothers
correlate n_siblings n_check
|
|
|