Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 73337

Deleting observations by common chracteristic

$
0
0
Hi Everyone,

I know, this might sound obvious, but it is not quite.

I am trying to drop all the observations that share a common household id, if, in a given household, there is a household head which is a women.

this table might make it clear:
Person id hhid hhrole sex
1 1 1 1
2 1 2 1
3 1 2 1
4 2 1 2
5 2 2 1
6 2 2 1
7 3 1 1
8 3 2 1
9 3 2 1
Where:
HHrole=1, means household head
HHrole=2, means household child.
Sex=1 means male
Sex=2 means female.

So what I am trying to do, is to drop all the observations from households that have a female household head.

The code i was trying to use was:

Code:
by hhid: drop if hhrole==1 & sex==2
but in this case it will only drop Person 4 and I need it to drop persons 4,5 and 6.

Any idea of how to code that? or any smart way around it?

Thanks for your kind help.

Viewing all articles
Browse latest Browse all 73337

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>