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
MERGE problem!!Problem with merge. I removed my duplicates and they are my only identical variables but I get "not …
What exists in e(first) at what position after ivreg2 ?After ivreg2, e(first) can be used. Then, I want to use Code: [#,#] right after the saved e(first) …
How to automate dummy variable adjustment for missing data?I run a fixed effects panel regression on survey data with missing values at my regressors (and DV).…
How to rearrange bars in bar graph with two variables and two over groupsHi all, I feel like I should know how to do this - but I'm trying to plot two variables with two se…
Reshape problemHi! I want to reshape my data wide to long, but state says that there is a problem. It days there ar…
Subscribe to:
Post Comments (Atom)
0 Response to Minutes off in datetime formatting
Post a Comment