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
interaction variable with i. operatorI want to run the following regression Code: reghdfe ABPROD BORDERLINE POST BORDERLINE_POST i.sic…
How to count each binary variables and only generate one variable to include all count information?Hi there, I have a set of binary variables and each of them stands for a certain health disease (e.…
Loop to create new variablesDear All I am working on a data set where I have to create (project) variables for age and position…
Creating a day variableI want to create a continuous day variable from January 1, 1991, to June 12, 1991. For instance, I e…
Double loops in Stata?Dear All, I want to do the following: Code: local replace replace forvalues i = 2007(1)2017 { for…
Subscribe to:
Post Comments (Atom)
0 Response to Minutes off in datetime formatting
Post a Comment