Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Making assignments in sequence on time variables

    Hi all,

    I’m writing a .do file that randomly assigns surveys to be administered each day to enumerators. However, there are certain survey slots that overlap with each other. The start_time and end_time variables show expected time to complete each survey (survey_id); sid (short for slot id) indicates enumerators’ work hours – 700 is between 9 am to 6 pm, 800 is 10 am to 7 pm, so on; and sur_id is the ith surveyor in each slot.

    The problem, however, is that when I make assignments after sorting the data by a random variable, there are a couple of surveys at the same time (or overlapping) slot assigned to the same surveyor. See below – surveyors 702, 805, 902 have different surveys assigned to them at same or overlapping time slots.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str4(pid survey_id) double(start_time end_time) str3(sid sur_id)
    "9170" "0041"   -1.89342e+12 -1.8934191e+12 "700" "701"
    "9183" "0045" -1.8934164e+12 -1.8934155e+12 "700" "701"
    "9154" "1414" -1.8934074e+12 -1.8934056e+12 "700" "701"
    "9184" "0033" -1.8934014e+12 -1.8933999e+12 "700" "701"
    "9151" "0181"   -1.89342e+12 -1.8934146e+12 "700" "702"
    "9173" "0202" -1.8934164e+12  -1.893411e+12 "700" "702"
    "9166" "1414" -1.8934074e+12 -1.8934056e+12 "700" "702"
    "9170" "0034" -1.8933999e+12 -1.8933984e+12 "700" "702"
    "9166" "0043" -1.8934182e+12 -1.8934173e+12 "800" "801"
    "9186" "0046" -1.8934155e+12 -1.8934146e+12 "800" "801"
    "9169" "1410" -1.8934092e+12 -1.8934074e+12 "800" "801"
    "9180" "0031" -1.8934044e+12 -1.8934029e+12 "800" "801"
    "9188" "0032" -1.8934017e+12 -1.8933984e+12 "800" "801"
    "9164" "0162" -1.8933948e+12 -1.8933912e+12 "800" "801"
    "9179" "0182" -1.8934164e+12  -1.893411e+12 "800" "805"
    "9158" "0049" -1.8934128e+12 -1.8934119e+12 "800" "805"
    "9164" "0031" -1.8934044e+12 -1.8934029e+12 "800" "805"
    "9152" "0032" -1.8934029e+12 -1.8934014e+12 "800" "805"
    "9166" "0162" -1.8933948e+12 -1.8933912e+12 "800" "805"
    "9188" "0047" -1.8934146e+12 -1.8934137e+12 "900" "902"
    "9167" "0048" -1.8934137e+12 -1.8934128e+12 "900" "902"
    "9151" "1414" -1.8934074e+12 -1.8934056e+12 "900" "902"
    "9174" "1414" -1.8934074e+12 -1.8934056e+12 "900" "902"
    "9172" "0033" -1.8934014e+12 -1.8933999e+12 "900" "902"
    "9185" "0033" -1.8934014e+12 -1.8933999e+12 "900" "902"
    "9182" "0162" -1.8933948e+12 -1.8933912e+12 "900" "902"
    end
    format %tchh:MM start_time
    format %tchh:MM end_time

    Is there a way to keep track of the required time needed to complete the survey initially assigned before assigning the next? Ideally, I would like to assign a survey to someone and create a timer that tracks when he/she’s available next, and only if the next survey start_time is after the current assignment's end_time will the same person be given another survey.

    Thanks so much – I really, really appreciate your help! Looking forward to learning your thoughts and suggestions.

  • #2
    You didn't get a quick answer. If you provided us your code so far for assignments, it might help.

    I'm wondering if you want to do loops so you assign the first survey to each respondent, than then assign the second where you pick a different time if it overlaps with the first, and so on.

    Comment

    Working...
    X