Monday, November 23, 2020

How to assign the same value to all members of a group if a condition on a certain variable occures AT LEAST once in the same group

Hi Statalist experts,

I would need a little help. I'm working with a dataset containing the following 3 variables:
1) household identifier (idhh)
2) individual identifier (idpers)
3) demographic age (dag)

I would like to create a new variable (var1) who assigns value 1 to all the members of a household if there is AT LEAST an individual with dag<18 in that same household (same idhh), and zero otherwise.
How can I translate this command in Stata language?
Thanks in advance for your help!

Andrea

No comments:

Post a Comment