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
Why cannot I add note to this graph by using the following code?twoway (scatter astate year) (scatter awagepre year, yaxis(2)title(wage premium)) , ytitle(State emp…
Making it so that stset works when birth and death happen in the same yearI'm working on a project in which I need to perform survival analysis on a sample of firms. When I s…
twoway connected or xtlineYear Country FDI year 2000 Cambodia 4.0501412 2000 2001 Cambodia 3.742602 2001 2002 Cambodia 3.38289…
Person-Specific IndicatorI have firm-year level data. I want to create person-specific indicators (not firm-specific). Howeve…
Location Specific EffectsHello, I am estimating a regression model predicting the odds of openness to PREP among foreign born…
Subscribe to:
Post Comments (Atom)
0 Response to Minutes off in datetime formatting
Post a Comment