Hello,
I am working on a load profile with 30-minute invervals of electricity demand that I wish to collapse into hourly demand in Stata. In order to do so, I have converted a string variable to a date-time format using the clock function in Stata:
gen DateTime2 = clock(DateTime, "20YMDhm")
format %tcMon_dd,_CCYY_HH:MM DateTime2
The problem is that the minutes are slightly off. DateTime in the list below is the string variable and DateTime2 is the converted variable. As you can see, 1.30 becomes 1.29 and so on.
list DateTime in 1/10
+------------------+
| DateTime |
|------------------|
1. | 2018-07-01 00:30 |
2. | 2018-07-01 01:00 |
3. | 2018-07-01 01:30 |
4. | 2018-07-01 02:00 |
5. | 2018-07-01 02:30 |
|------------------|
6. | 2018-07-01 03:00 |
7. | 2018-07-01 03:30 |
8. | 2018-07-01 04:00 |
9. | 2018-07-01 04:30 |
10. | 2018-07-01 05:00 |
+------------------+
. list DateTime2 in 1/10
+-------------------+
| DateTime2 |
|-------------------|
1. | Jul 1, 2018 00:30 |
2. | Jul 1, 2018 01:00 |
3. | Jul 1, 2018 01:29 |
4. | Jul 1, 2018 01:59 |
5. | Jul 1, 2018 02:30 |
|-------------------|
6. | Jul 1, 2018 03:00 |
7. | Jul 1, 2018 03:29 |
8. | Jul 1, 2018 03:59 |
9. | Jul 1, 2018 04:30 |
10. | Jul 1, 2018 05:01 |
+-------------------+
I wish to collapse the data to hourly demand instead of half-hourly, but I need to correct this error first. Any ideas on how to do so are highly appreciated!
Milla
Related Posts with Minutes off in datetime formatting
Contract year reshapeDear Statalists, Hope all is well. I am dealing with the contract data with specific contract star…
Dates got omitted due to collinearity in fixed-effects regression modelHello, I run a regression to examine what has an impact on the decision to sell a stock on the stoc…
Removing duplicatesHi, I have a dataset which i want to be uniques with the variables gvkey, fyear and loc. But there …
plot the results of a 2sls regression with fixed effectsHello, I want to plot the results of a 2sls regression with fixed effects for different values of a …
Bayesian analysis in StataI will be leading a workshop on Bayesian analysis, where I need to make all Baysian analyses as simp…
Subscribe to:
Post Comments (Atom)
0 Response to Minutes off in datetime formatting
Post a Comment