Hi Statalist;
I am working with a dataset that has households identified by a household id # and then family members uniquely identified by that household id # and a line number for their place in the household.
My question is: if some number of individuals in my whole dataset have a problem, and I want to flag their whole household as containing this issue so I can create a dataset of all individuals of a household where a member has this issue, what is the fastest way to do this?
In other words, after I generate problem = 1 for person 2 in household x, how do I mark everyone in household x as having problem = 1? (And, simultaneously, do that for every relevant household in this large dataset). So far I've tried using merge and then I tried collapse and merge, but with both attempts I just got turned around by having so many merges as my problem also originates in a merge... surely there's an easy way to do this?
Many thanks for your help!
I am working with a dataset that has households identified by a household id # and then family members uniquely identified by that household id # and a line number for their place in the household.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double tucaseid byte(tulineno teage) 20030100013848 1 36 20030100013848 2 39 20030100013848 3 11 20030100013848 4 9 20030100014165 1 51 20030100014165 2 50 20030100014165 3 14 20030100014165 4 14 20030100014550 1 33 20030100014550 2 39 20030100014550 3 15 20030100014550 4 14 20030100014550 5 3 end
In other words, after I generate problem = 1 for person 2 in household x, how do I mark everyone in household x as having problem = 1? (And, simultaneously, do that for every relevant household in this large dataset). So far I've tried using merge and then I tried collapse and merge, but with both attempts I just got turned around by having so many merges as my problem also originates in a merge... surely there's an easy way to do this?
Many thanks for your help!
Comment