Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Creating variables with ordering information


From   "Hui Wang" <jackie_stata@hotmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Creating variables with ordering information
Date   Sat, 05 Aug 2006 21:19:38 +0000

Hi,

I have a data set with 3 variables listed as following:

1) HH_id:        Household id. To identify households.
2) Birth_order: Birth_order of individual in the household. To identify
individuals.
3) Gender:      Sex of each individual.

Now I want to creat two variables: nboy and ngirl, which counts, for each
individual in a given household, how many boy (girl) the household already
have when that individual was born.

The following is a example:

HH_id| Birth_order | Gender | nboy | ngirl|
1      | 1               | F          | 0      | 0
1      | 2               | M         | 0      | 1
1      | 3               | M         | 1      | 1
2      | 1               | F         | 0       | 0
2      | 2               | F         | 0       | 1
2      | 3               | M        | 0       | 2
2      | 4               | F         | 1       | 2
2      | 5               | M         | 1       | 3

My question is, given "HH_id", "Birth_order", and "Gender", how to program
to generate "nboy" and "ngirl"? Thank you very much.

Jackie

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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