Announcement

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

  • Converting a string variable to a time

    Hi all,
    Sorry, I'm still quite new to Stata so bear with me!
    I have a variable with a large series of times in the format HH:MM:SS,milliseconds. For example, 08:56:01,070. I'm trying to convert this variable to a format recognisable by stata to use in a time series.
    I've tried variations on:
    generate double time2 = clock(time, "hms") but am just getting a series of dots in the new variable column.
    I would appreciate any help you could give me on this!

  • #2
    The problem arises from the comma as decimal point. Use -subinstr()- to replace those with periods (dots, '.'), and then your code will work. (Note: -set dp comma- will not solve this problem.)

    Comment


    • #3
      Thanks very much for that! Worked perfectly!

      Comment

      Working...
      X