Hello,

I’m working with a time use database with information at the individual and household level. I have a couple of variables about who in the household the individual is doing domestic work for. For example, there is a question “Do you cook for someone in the household” if the individual responds affirmative, then they have to report the order of the member of the household they cook for. I want to create an indicator that takes the value of 1 if the person being cooked is younger than 6 and the value of 2 if its older than 65. I'm not sure how to loop through the observations in this case.


The data I have looks like this:

idhogar order age cookfor ord_cookfor
1 4 1 0 .
1 3 7 0 .
1 2 57 0 .
1 1 42 1 4
2 5 67 0 .
3 7 48 0 .
3 6 57 0 .
3 8 21 0 .
4 11 65 1 9
4 10 67 0 .
4 9 30 0 .
5 14 59 0 .


Thank you,

Tessa