Hi there!

Pardon me for a stupid thread title. I didn't know what to call it.

I have the household roster that looks like following. All respondents were asked about their other household members as well.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte hhid str6 name str15(relation where)
1 "ben"    "self"            "here"           
1 "larry"  "father"          "here"           
1 "emma"   "mother"          "here"           
2 "rachel" "self"            "here"           
2 "nathan" "son"             "another country"
2 "lydia"  "daughter-in-law" "here"           
2 "morris" "grandson"        "here"           
2 "clara"  "granddaughter"   "here"           
end
Now, I require the following:

1. I only need those observations where relation == "self" (i.e. I am only keeping the respondents' observations, and dropping info about their household members.)
2. I will, however, need a variable on whether the household has a migrant.

In that case, it should throw me the following cleaned data:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte hhid str6 name byte has_migrant
1 "ben"    0
2 "rachel" 1
end
Is there any way I can do that? I thought about using collapse, but I am not sure how.