Announcement

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

  • time variable.

    Dear All, I was asked this question (https://bbs.pinggu.org/thread-7058778-1-1.html). The data is
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str8 aid str6 H1GH50
    "57100270" "12:00A"
    "57101310" "11:00P"
    "57103171" "10:00P"
    "57103869" "12:00P"
    "57104553" "11:00P"
    "57104649" "09:30P"
    "57104676" "09:00P"
    "57109625" "09:30P"
    "57110897" "10:00A"
    "57111071" "10:00P"
    "57111786" "09:00P"
    "57113943" "10:00P"
    "57116359" "11:00P"
    "57117542" "12:00A"
    "57117997" "09:00P"
    "57118381" "10:00P"
    "57118943" "11:30P"
    "57120005" "10:00P"
    "57120046" "10:00P"
    "57120371" "01:00A"
    end
    where `A' and `P' mean `AM' and `PM', respectively. How can I transform `H1GH50' into a standard Stata time variable? Thanks.
    Ho-Chuan (River) Huang
    Stata 17.0, MP(4)

  • #2
    Code:
    gen double time = clock(H1GH50+"M", "hm")
    format time %tcHH:MM
    If you don't like that particular display format, just use whatever you like; the underlying time variable is correctly calculated by the -gen- command.

    Comment

    Working...
    X