Following is a response from Senior DHS staff member, Tom Pullum:

I will post below some Stata lines that describe how I would calculate the bottom line of the table, but I don't match the table either. My n for the table is about 20,000 cases too high, and several of the means or percentages are off.

I don't know how to interpret "either sex", but this should not explain why I do not match the mean ideal number of boys (I get 1.0; the table gives 1.1) but I do match the mean number of girls (I get 0.9 and the table gives 0.9). I am off for both of the percentages you asked about. The footnote says to omit (from the entire table) cases with non-numeric responses to the ideal number of children or sons or daughters. I did this, with or without also dropping from the table the cases with non-numeric responses to "either sex", but nothing gives a match.

I am not motivated to put more effort into trying to match the table. This is probably just another problematic table in the NFHS-5 report. If you want to do further research on this topic, I suggest that you use your own coding and ignore the final report table. If anyone else can get a match, please post your code.

use " IAIR7DFL.DTA", clear
* No idea what v629 means
gen ch=v613 if v613<96 & v627<96 & v628<96 & v629<96
gen boys=v627 if v613<96 & v627<96 & v628<96 & v629<96
gen girls=v628 if v613<96 & v627<96 & v628<96 & v629<96
gen either=v629 if v613<96 & v627<96 & v628<96 & v629<96
label variable ch "Ideal number of chv613<96 | v627<96 | v628<96ildren"
label variable boys "Ideal number of boys"
label variable girls "Ideal number of girls"
gen bgpref=.
replace bgpref=1 if boys>girls & boys<.
replace bgpref=2 if boys==girls & boys<.
replace bgpref=3 if boys<girls & girls<.
label define bgpref 1 "more boys" 2 "same number" 3 "more girls"
label values bgpref bgpref
gen more_boys=0 if bgpref<.
replace more_boys=100 if bgpref==1
gen more_girls=0 if bgpref<.
replace more_girls=100 if bgpref==3
gen any_boys=0 if boys<.
replace any_boys=100 if boys>0 & boys<.
gen any_girls=0 if girls<.
replace any_girls=100 if girls>0 & girls<.
tab bgpref [iweight=v005/1000000]
tabstat boys girls either more_boys more_girls any_boys any_girls [fweight=v005], statistics(mean) format(%6.1f)