A preliminary note: The HEALTH variable is only available in ASEC samples. So, you will not be able to include the basic monthly samples in your analysis. This is not much of an issue, since in general, you will want to perform any analysis in either the ASEC samples or the basic monthly samples and not both. This is because the same individuals are included in the ASEC and basic monthly samples.
I’ll discuss some ideas for how to create each of these variables, one at a time:
(1) I’m not sure how you are defining your “individual of interest.” This code will be influenced by how you are defining this individual within each household. One way to do this is to generate a dummy variable for all observations that equals 1 if HEALTH>=4 (e.g., “fair or poor health”). Then, I’d create a dummy variable that equals 1 if the person is your “individual of interest.” Finally, you can replace the values of the “bad health” dummy variable for your “individual of interest” with a zero.
(2) The following code will count the number of individuals within households that report “bad health.” Note: households are slightly different than families, because multiple families can live within a household.
egen count = total(bad_health==1), by(serial)
If you want to perform this count within families, then the code will look something like this:
egen count = total(bad_health==1), by(serial famunit)