Hello, gang
I was wondering if someone could help me with a problem that has been bugging me for quite some time. Can't seem to find any sources on where to find it explained specifically (i've read through most i can find ++ in 24: Working with dates and times). If anyone knows where i could find a document that gives an explanation towards solving my issue, i am, of course, more than happy to read it.
I got a date variable called "date" which shows me the timestamp for when a respondent finished answering a survey. It is displayed in a string with m/d/y/h/m. Example: "12/26/2022 08:43". I generated a numeric "version" of this time variable by using the code
"generate double timestamp = clock(date," MDY hm")"
and then
"format timestamp %tc" in order to make it more managable.
What I would like to do is to create a variable that just shows the literal time (f.ex 08:43) and then group every timestamp that is within the hours 00:00 - 00:59, 01:00 - 01:59... and so on. F.ex giving the time interval 00:00 - 00:59 the value 0 and 01:00 - 01:59 the value 1... and so on. My goal is to run a regression to see if answering the survey at different times affects the answers. Also, if its possible, I would like to do a variable for different days of the week (monday - sunday), what week it is (01.01 - 07.01 = week 1), month and year.
Would greatly appreciate any help!
Kind regards
Tor
I was wondering if someone could help me with a problem that has been bugging me for quite some time. Can't seem to find any sources on where to find it explained specifically (i've read through most i can find ++ in 24: Working with dates and times). If anyone knows where i could find a document that gives an explanation towards solving my issue, i am, of course, more than happy to read it.
I got a date variable called "date" which shows me the timestamp for when a respondent finished answering a survey. It is displayed in a string with m/d/y/h/m. Example: "12/26/2022 08:43". I generated a numeric "version" of this time variable by using the code
"generate double timestamp = clock(date," MDY hm")"
and then
"format timestamp %tc" in order to make it more managable.
What I would like to do is to create a variable that just shows the literal time (f.ex 08:43) and then group every timestamp that is within the hours 00:00 - 00:59, 01:00 - 01:59... and so on. F.ex giving the time interval 00:00 - 00:59 the value 0 and 01:00 - 01:59 the value 1... and so on. My goal is to run a regression to see if answering the survey at different times affects the answers. Also, if its possible, I would like to do a variable for different days of the week (monday - sunday), what week it is (01.01 - 07.01 = week 1), month and year.
Would greatly appreciate any help!
Kind regards
Tor
Comment