1. As to your first question, you can do the following:
gen count=.
sort hhid
by hhid: replace count=_n
2. the second question can be done by just using -merge-
i.e. merge hhid using xxx.dta
----- Original Message -----
寄件者: "Kompal Sinha" <[email protected]>
收件者: <[email protected]>
傳送日期: Sunday, November 10, 2002 7:42 PM
主旨: st: merging household and person data
Hi there,
I have two data files: first containing the household(HH) data and second
containing person wise data for the corresponding HH.
I want to do the following:
1) In the person wise file which looks like this:
HHID religion
12345 1
12345 2
12345 3
12334 4
12334 4
12334 4
12334 5
I want to generate a new variable count such as it counts the number of
persons in a particular household and assigns a number to it, like:
HHID religion count
12345 1 1
12345 2 2
12345 3 3
12334 4 1
12334 4 2
12334 4 3
12334 5 4
2) I want to merge the HH data and person data. The hh data has 60000 obs
and the person data has 180000 obs. I want to put the HH income from the
household data in front of each person of that HH in the person data like:
HHID religion count HHIncome
12345 1 1 50
12345 2 2 50
12345 3 3 50
12334 4 1 100
12334 4 2 100
12334 4 3 100
12334 5 4 100
As to this part, you can use:
How do I proceed?
Thanks in advance,
Kompal
*
* 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/
*
* 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/