Hi Statalist,
I have been lost in coding since I started to deal with this issue and here is my problem. In the example data below, I give you the IDs of individuals and the code of action they take during the day(irrelevant ones are removed). Action's being equal to 111 means that that person is at work. Time is basically the amount of time devoted to that activity. Start and End in fact represents the hours on which a particular activity is initiated and finished, yet they are stated in terms of minutes; for example, 240 means 4:00 AM.
Here is what I would like to do. I want to calculate the how much of work time of these two individuals overlap. For this particular example, the answer is 230. Therefore, I want a create a column where there are 230s as long as FamilyID, which shows that those individuals belong to the same family, equals 1.
(The order of the variables: FamilyID, ID, Action,Time, Start, End)
I have been lost in coding since I started to deal with this issue and here is my problem. In the example data below, I give you the IDs of individuals and the code of action they take during the day(irrelevant ones are removed). Action's being equal to 111 means that that person is at work. Time is basically the amount of time devoted to that activity. Start and End in fact represents the hours on which a particular activity is initiated and finished, yet they are stated in terms of minutes; for example, 240 means 4:00 AM.
Here is what I would like to do. I want to calculate the how much of work time of these two individuals overlap. For this particular example, the answer is 230. Therefore, I want a create a column where there are 230s as long as FamilyID, which shows that those individuals belong to the same family, equals 1.
(The order of the variables: FamilyID, ID, Action,Time, Start, End)
Code:
FamilyID ID Action Time Start End 1 159 . 180 240 420 1 159 . 10 420 430 1 159 . 20 430 450 1 159 . 30 450 480 1 159 . 60 480 540 1 159 111 210 540 750 1 159 . 30 750 780 1 159 111 180 780 960 1 159 . 60 960 1020 1 159 111 180 1020 1200 1 159 . 60 1200 1260 1 159 . 30 1260 1290 1 159 . 20 1290 1310 1 159 . 10 1310 1320 1 159 . 60 1320 1380 1 159 . 60 1380 1440 1 160 . 180 240 420 1 160 . 120 420 540 1 160 . 10 540 550 1 160 . 10 550 560 1 160 . 40 560 600 1 160 . 60 600 660 1 160 . 20 660 680 1 160 . 100 680 780 1 160 . 120 780 900 1 160 111 60 900 960 1 160 . 30 960 990 1 160 111 140 990 1130 1 160 . 10 1130 1140 1 160 111 60 1140 1200 1 160 . 60 1200 1260 1 160 . 30 1260 1290 1 160 . 10 1290 1300 1 160 . 20 1300 1320 1 160 . 60 1320 1380 1 160 . 20 1380 1400 1 160 . 40 1400 1440
Comment