Announcement

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

  • How to get hourly data

    I am working on an assignment where I want to do ARMA and ARMIA analysis over electricity prices. The dataset includes over 50000 observations over five years. I have figured out how to destring my time variable from stata. However, I need to have specifics from the datetime in separate columns in order to analyse how prices are effected on hourly basis in the format 00-23, monthly basis in the format 1-12 and yearly basis. When I try to separate these I either get hours counted from 1960 or just dots in the cells. I have no idea what is wrong here and can“t find any guidelines on forums here.

    destring FCRDuppPrisEURMW, gen(price)
    drop FCRDuppPrisEURMW
    ssc install dataex
    rename Period Time
    gen double Time2 = clock(Time, "DMYhms")
    format Time2 %tc
    gen Hours = hours(Time2)
    gen month = month(Time2)

    Time price Time2 Hours month
    01jan2017 00:00:00 4.657 01jan2017 00:00:00 499680
    01jan2017 01:00:00 4.65 01jan2017 01:00:00 499681
    01jan2017 01:59:59 4.65 01jan2017 01:59:59 499682
    01jan2017 03:00:00 4.65 01jan2017 03:00:00 499683
    01jan2017 04:00:00 4.65 01jan2017 04:00:00 499684
    01jan2017 04:59:59 5.298 01jan2017 04:59:59 499685
    01jan2017 06:00:00 5.235 01jan2017 06:00:00 499686
    01jan2017 07:00:00 4.657 01jan2017 07:00:00 499687
    01jan2017 07:59:59 4.682 01jan2017 07:59:59 499688
    01jan2017 09:00:00 4.652 01jan2017 09:00:00 499689
    01jan2017 10:00:00 4.625 01jan2017 10:00:00 499690
    01jan2017 10:59:59 4.623 01jan2017 10:59:59 499691
    01jan2017 12:00:00 4.528 01jan2017 12:00:00 499692

  • #2
    I think you need:
    Code:
    gen Hours = hh(Time2)
    gen month = month(dofc(Time2))

    Comment


    • #3
      Thank you so much Hemanshu! It worked fine!

      Comment

      Working...
      X