Hi Hae-Bong,
You can get it through the following steps:
First, you should generate a new variable by hhid.
Command: bysort hhid: gen rank=_n
Next, you can generate another varible by hhid.
Command: bysort hhid: egen sum=sum(rank)
Then, drop all the observations if sum is not equal 3.
Command: drop if sum != 3
You will gent the required result matched by hhid.
Cheers
Tianxin
--- In [email protected], hbwoo@m... wrote:
> Dear all,
> I want to make a matched-couple data set. All respondents are
married in this
> data set. What I want to know is how to drop non-matched case like
the
> following first household (hhid=0000045). or keep matched-couple
cases.
> At first I thought I can use "merge" command after separating
husbands from
> wives, but it seems that's not true. Would you give me some
suggestions? or
> where can I find out some information about that? I couldn't find
it.
>
> Thanks,
> Hae-Bong
>
> hhid: household id
> sn: serial number within each household
> relate: relationship (1=householder / 2=husband or wife)
>
>
> . by hhid: list hhid sn relate sex
>
> --------------------------------------------------------------------
-----------
> -> hhid = 0000045
>
> +--------------------------------+
> | hhid sn relate sex |
> |--------------------------------|
> 1. | 0000045 01 01 1 |
> +--------------------------------+
>
> --------------------------------------------------------------------
------------>
> hhid = 0000223
>
> +--------------------------------+
> | hhid sn relate sex |
> |--------------------------------|
> 1. | 0000223 01 01 1 |
> 2. | 0000223 02 02 2 |
> +--------------------------------+
>
> --------------------------------------------------------------------
------------>
> hhid = 0000378
>
> +--------------------------------+
> | hhid sn relate sex |
> |--------------------------------|
> 1. | 0000378 01 01 1 |
> 2. | 0000378 02 02 2 |
> +--------------------------------+
>
> *
> * 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/