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
Importing specific cells from multiple excell sheets in multiple workbooksHello everyone I have a problem I hope I can get your help with. I'm a first time poster, so please…
Ultimatch - Nearest Neighbor, Radius, Coarsened Exact, Percentile Rank and Mahalanobis Distance Matching in one PackageHi everyone, for all that are interessted in matching (especially by Mahalanobis Distance)... ulti…
Specifying a GARCH(1,1) modelHi, I am trying to find the conditional variance for multiple countries' HP filter ln of GDP using t…
Creating an index with missing data in time seriesDear Statalist forum, I would like to ask the following. I have a time series with missing data for…
Issue with an Independent variable consisting of Non Mutually Exclusive Categories, whereby one category perfectly predicts the outcome.Hi Statalist, I'm having a number of problems with my Probit model. I am attempting to model predic…
Subscribe to:
Post Comments (Atom)
0 Response to Minutes off in datetime formatting
Post a Comment