[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: RE: constructing sibling sex composition

From   "Nick Cox" <>
To   <>
Subject   RE: st: RE: constructing sibling sex composition
Date   Mon, 8 Dec 2008 18:50:43 -0000

Martin Weiss already pointed you in the direction of the data management
FAQs. When I read your first posting, it seemed that the most relevant
FAQ was 

FAQ     . . Creating variables recording prop. of the other members of a
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N.
J. Cox
        4/05    How do I create variables summarizing for each
                individual properties of the other members of a

However, it now seems that you have quite a different data structure
from that assumed in the FAQ or by previous contributors to the thread.
No wonder this thread is moving so slowly: without precise information
at the outset, people can easily just waste their time. 

You don't make it clear even now, but I guess from this that sex is
coded 1 for female and 0 for male. If not, change the code below. 

A loop from first principles is 

gen boynum = 0 
gen girlnum = 0 

forval i = 1/12 { 
	replace boynum = boynum + (sexsib`i' == 0) if `i' <= numsib 
	replace girlnum = girlnum + (sexsib`i' == 1) if `i' <= numsib

It may be that you can do it with 

egen boynum = anycount(sexsib*), values(0) 
egen girlnum = anycount(sexsib*), values(1)

but much depends on what is stored for any siblings beyond -numsib-. If
sex is missing if there is no such sibling. The -egen- route should


Nirina F

I tried this:
egen boynum= count(sexsib*==1), by (hhid)

but of course sexsib* came out as invalid name.
I have variables sexsib1 , sexsib2, .... sexsib12. These are the sex
of the siblings and the siblings vary from 0 to 12 depending on the
number of siblings in the household.
But I have also numsib whcih tells me the number of siblings.

I guess I have to write a loop :

. forvalues t=numsib{
  2. egen boynum= count(sexsib`t'==1), by(hhid)
  3. }
but then I get   " invalid syntax
r(198);" because I have an error in my code

<big snip> 

Nirina F

>>> I have a household survey data and would like to construct a
>>> that indicates the sex composition of the respondent's siblings.
>>> I have the year of birth and sex of siblings.
>>> Does anyone know how to do this because the number of siblings vary
>>> respondent and the minimum number of sibling  is 0 and maximum is

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index