[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Jan Sauermann" <jan.sauermann@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st:Measuring two time-spells |

Date |
Fri, 25 Jul 2008 14:43:59 +0200 |

Thanks a lot for the answer, Valérie. To be honest, I found a solution in the meantime. The main problem was to make Stata comparing the right spells of two workers. I think that will always be rather complicated. The new idea I had is actually simple (and works pretty fine, but takes a long time to compute): basically, I generate a dummy for each person (1 = at work, 0 = not at work) for each minute of my observation period (I started with seconds but that make a huge dataset). The result is a new dataset which looks like this: minute dummy_worker1 dummy_worker2 etc. 1000001 1 1 1000002 0 1 1000003 1 0 Then, I can easily generate a dummy if two dummies are both one in the same minute. The column sum of the minutes gives me then the aggregate time for two persons when they were together at work. So, the problem is solved ;-) Best regards + thanks again for your effort, Jan On Fri, Jul 25, 2008 at 8:37 AM, <orozco@toulouse.inra.fr> wrote: > Dear Jan, > > What about generating variables indicating, by date (extracted via the login), > the maximum hour of entry (Max of login) and the minimum hour of entry (Min of > logout) between workers. Then, you can easily calculate the difference of these > two times, which corresponds to the intersection of two workers. Look at this > example with only 2 workers: > > date worker login logout maxlogin > minlogout inter > 16-janv-08 1 16/01/2008 13:55 16/01/2008 22:34 16/01/2008 13:55 16/01/2008 > 22:34 8:38 > 16-janv-08 2 16/01/2008 07:50 16/01/2008 23:00 16/01/2008 13:55 16/01/2008 > 22:34 8:38 > 20-janv-08 1 20/01/2008 14:26 20/01/2008 15:52 20/01/2008 14:26 20/01/2008 > 15:52 1:25 > 20-janv-08 2 20/01/2008 10:05 20/01/2008 19:30 20/01/2008 14:26 20/01/2008 > 15:52 1:25 > > Hope this helps you. > > Valérie > > > ------------------------------- > Valérie OROZCO > Toulouse School of Economics (INRA-GREMAQ) > 21, allée de Brienne > F-31000 Toulouse, France > > MF 426 > +33 5 61 12 85 91 > ------------------------------- > > ________________________________________ > From "Jan Sauermann" <jan.sauermann@gmail.com> > > To statalist@hsphsun2.harvard.edu > > Subject st: Measuring two time-spells > Date Wed, 23 Jul 2008 18:15:30 +0200 > ________________________________________ > Dear Statalist. > > my setting is the following: I observe two workers (i and j) for about > one year. They are at the same workplace; I have information on when > they enter, and when they leave work (my time data is continuous in > seconds). I would like to have a third variable which gives me > information when they are both at the workplace. Eventually, I would > like to have an aggregate variable, e.g. for week 40 of year 2007, how > many hours they have spent together at work. > > The main problem is that they have changing shifts and changing number > of hours at one day. I.e., at one day, worker i starts after worker j, > but leaves earlier; another day, i starts first and leaves first. It > can also be more complicated if i has a long shift and j jas two short > shifts during this period. > > To make it graphically, I would like to measure the following distance > (I hope that works properly): > > Time t ------------------------------------> T > i at work <----------> > j at work <-------> > I want: <---> > > > My data now looks like this (only a minor part): > > | worker login logout spell | > |----------------------------------------------------------| > 1. | 1 16jan2008 13:55:35 16jan2008 22:34:13 1 | > 2. | 1 20dec2007 14:26:54 20dec2007 23:00:14 2 | > 3. | 1 03may2008 07:49:56 03may2008 11:10:25 3 | > > 57. | 2 02jan2008 17:00:08 02jan2008 23:06:53 1 | > 58. | 2 01dec2007 13:32:37 01dec2007 19:33:34 2 | > 59. | 2 09jan2008 17:02:59 09jan2008 23:04:12 3 | > > 178. | 3 09may2008 08:00:12 09may2008 14:00:36 1 | > 179. | 3 06nov2007 14:30:45 06nov2007 19:29:57 2 | > 180. | 3 09oct2007 13:31:02 09oct2007 19:30:11 3 | > > [...] > > > This example now is just for two persons. I think, when having a > solution for worker i and j, it can be easily extended to N workers by > looping. > > > I hope that it is clear what I mean. It would be really nice if > somebody could help me!! > > Best regards, > > Jan > > -- > Jan Sauermann (<j.sauermann@roa.unimaas.nl>) > Research Centre for Education and the Labour Market (ROA) / Maastricht > University > > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ > * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**RE:st:Measuring two time-spells***From:*orozco@toulouse.inra.fr

- Prev by Date:
**Re: st: IV with missing values** - Next by Date:
**st: Graphing Question** - Previous by thread:
**RE:st:Measuring two time-spells** - Next by thread:
**st: Graphing Question** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |