From 54642d74341450876b113662f09d6edb3f54f9a0 Mon Sep 17 00:00:00 2001 From: Ben Anderson <b.anderson@soton.ac.uk> Date: Fri, 30 Jan 2015 18:17:24 +0400 Subject: [PATCH] fixed starttime & haflhour miscoding --- ONS-TU-2005-convert-to-long.do | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/ONS-TU-2005-convert-to-long.do b/ONS-TU-2005-convert-to-long.do index 29322d3..3963d86 100644 --- a/ONS-TU-2005-convert-to-long.do +++ b/ONS-TU-2005-convert-to-long.do @@ -84,6 +84,20 @@ reshape long pact sact lact, i(serial) rename _j t_slot * t_slot now has values 1 -> 144 (10 minute slots) +* change to 0 -> 143 to make time & date easier +replace t_slot = t_slot - 1 + +* which hour is it? +gen t_hourfromslot = floor(t_slot/6) +replace t_hourfromslot = 0 if t_hourfromslot == 24 + +* diary starts at 04:00 +* NB this puts > 00:00 to the start of the diary day - remember this if doing sequences through 04:00 +* also some charts will show discontinuities at 04:00 +gen t_hour = t_hourfromslot + 4 + +* fix the t_hour > 24 problem +replace t_hour = t_hour - 24 if t_hour > 23 * calculate minute from slot (end of slot) gen min = mod(t_slot,6) @@ -94,15 +108,6 @@ replace t_min = 30 if min == 3 replace t_min = 40 if min == 4 replace t_min = 50 if min == 5 -* which hour is it? -gen t_hour = ceil(t_slot/6) -* diary starts at 04:00 -* NB this puts > 00:00 to the start of the diary day - remember this if doing sequences through 04:00 -* also some charts will show discontinuities at 04:00 -replace t_hour = t_hour + 3 -* fix the 'following hour' problem -replace t_hour = t_hour + 1 if t_min == 0 - * fix dates * Feb: we are going to assume this was the first full week of feb where Monday was the 7th gen t_day = ba_dow + 6 if month == 1 -- GitLab