Announcement

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

  • generating time duration from strings

    Hi Everyone,
    I am using Italian Time use data. Since I have the time at which an episode begins and the time at which the episode ends, is there a way to tell STATA that those strings are duration (i.e. is there a way to generate the duration of an episode once having the time at which you start doing that activity and the time at which you end doing it) ?
    Since my data are confidential I will post an example of my dataset:
    Code:
    input str2(starthour startminute endhour endminute)
    "04" "00" "09" "50"
    "09" "50" "10" "00"
    "10" "00" "10" "10"
    "10" "10" "11" "30"
    "11" "30" "12" "50"
    "12" "50" "15" "00"
    "15" "00" "16" "00"
    "16" "00" "16" "50"
    "16 "50" "17" "50"
    "17" "50" "18" "00"
    "18" "00" "18" "30"
    "18" "30" "18" "50"
    "18" "50" "21" "00"
    "21" "00" "21" "30"
    "21" "30" "22" "00"
    "22" "00" "22" "40"
    "22" "40" "04" "00"
    where "starthour" is the hour at which you start doing a given activity, "startminute" is the minute in which you start a given activity, "endhour" and "endmin" is the time at which you end doing that activity!
    Thank you all in advance,
    Andrea

  • #2
    I'm not sure I understand your question, may be you are looking for something like this:
    Code:
    g Start=Chms(real(starthour),real(startminute),00)
    g End=Chms(real(endhour),real(endminute),00)
    g duration=End-Start
    format Start End duration %tcHH:MM
    You didn't provide any information about the existence of episodes with duration beyond 24 hours, the above code assumes limits of 24 hours for episodes.

    Comment


    • #3
      Thank you very much for your answer, anyway I have a time diary for each individual and it was filled between the 4am of day t and the 4 am of the day t+1

      Comment

      Working...
      X