Dear all,
I have a dataset (in .xlsx) with market data on a daily basis for seven years. For each day, I have 24 observations, i.e. one per hour. The dataset consists of the following columns: "Date - Hour - Price - Volume". I would like to run rolling regression to create expected price estimates using previous observations only. Unfortunately, I can't set up "Date" as time series variable using "tsset" because there are more than one observation for each day.
I was therefore thinking to create a datetime variable that can be used as timeseries variable, but I seem to have several problems with the compatibility between Stata and Excel. If I create the datetime variable directly in Excel then Stata suddenly changes some of the times that were e.g. "02:00:00" in Excel into "01:59:59" in Stata after importing the dataset. Apart from it not looking very nice, it also prevents me to apply "tsset" as it no longer seems to be an integer.
A similar issue arises if I try to create the variable in Stata. For some reason, the "Hour" observation that was simply "00:00" in Excel is now already a datetime variable in Stata and reads "31dec1899 00:00". Combining "Hour" and "Date" does then no longer work and I also didn't manage to find out how to isolate the time from the "Hour" column while keeping it in the %tc format.
Hence, I would be very grateful for some help on how to circumvent these issues and how to set up a datetime variable that can be used with tsset.
I have attached an extract of the dataset I am using.
Thank you for your help in advance!
I have a dataset (in .xlsx) with market data on a daily basis for seven years. For each day, I have 24 observations, i.e. one per hour. The dataset consists of the following columns: "Date - Hour - Price - Volume". I would like to run rolling regression to create expected price estimates using previous observations only. Unfortunately, I can't set up "Date" as time series variable using "tsset" because there are more than one observation for each day.
I was therefore thinking to create a datetime variable that can be used as timeseries variable, but I seem to have several problems with the compatibility between Stata and Excel. If I create the datetime variable directly in Excel then Stata suddenly changes some of the times that were e.g. "02:00:00" in Excel into "01:59:59" in Stata after importing the dataset. Apart from it not looking very nice, it also prevents me to apply "tsset" as it no longer seems to be an integer.
A similar issue arises if I try to create the variable in Stata. For some reason, the "Hour" observation that was simply "00:00" in Excel is now already a datetime variable in Stata and reads "31dec1899 00:00". Combining "Hour" and "Date" does then no longer work and I also didn't manage to find out how to isolate the time from the "Hour" column while keeping it in the %tc format.
Hence, I would be very grateful for some help on how to circumvent these issues and how to set up a datetime variable that can be used with tsset.
I have attached an extract of the dataset I am using.
Thank you for your help in advance!
Comment