I'm running Stata 15 on a Mac OS. I recently conducted a survey across a period of a couple weeks. Basically, I'd like to determine whether the time of day in which respondents took the survey affected their responses. The problem is that the date/time variable I have is fixed to my time zone (EST). If possible, I'd like to create a variable wherein those that (for instance) took the survey either at 3PM PST or 3PM EST (etc.) are included/coded in the same category (i.e. 3PM on Wednesday). I'm not sure how to go about doing this, though. I do have a variable for time zone + offsets. The question is how I go about using them to create a standardized/time-zone-adjusted variable. Any input you can provide will be much appreciated.
Here are sample data that includes the original (string) date/time variable, the numeric date/time variable I created, and the timezone + timezone offsets.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str13 startdate float TOD long timezone byte timezoneutcoffset "7/5/21 19:39" 1.9411332e+12 3 -5 "7/5/21 20:02" 1.9411345e+12 3 -5 "7/5/21 21:46" 1.9411408e+12 6 -8 "7/5/21 22:58" 1.941145e+12 3 -5 "7/5/21 23:13" 1.941146e+12 6 -8 "7/5/21 23:12" 1.941146e+12 3 -5 "7/5/21 23:21" 1.9411464e+12 3 -5 "7/5/21 23:22" 1.9411466e+12 2 -6 "7/5/21 23:31" 1.941147e+12 6 -8 "7/6/21 0:46" 1.9411515e+12 2 -6 "7/6/21 0:26" 1.9411504e+12 3 -5 "7/6/21 1:07" 1.941153e+12 3 -5 "7/6/21 1:11" 1.941153e+12 3 -5 "7/6/21 1:16" 1.9411534e+12 6 -8 "7/6/21 1:22" 1.9411538e+12 3 -5 "7/6/21 1:30" 1.941154e+12 3 -5 "7/6/21 1:26" 1.941154e+12 5 -7 "7/6/21 1:59" 1.941156e+12 6 -8 "7/6/21 1:54" 1.9411556e+12 . . "7/6/21 2:20" 1.941157e+12 2 -6 "7/6/21 3:30" 1.9411614e+12 6 -8 "7/6/21 3:46" 1.9411623e+12 5 -7 "7/6/21 4:50" 1.9411662e+12 2 -6 "7/6/21 6:32" 1.9411723e+12 3 -5 "7/6/21 7:01" 1.941174e+12 3 -5 "7/6/21 7:10" 1.9411746e+12 3 -5 "7/6/21 7:15" 1.941175e+12 3 -5 "7/6/21 6:59" 1.941174e+12 3 -5 "7/6/21 7:32" 1.941176e+12 3 -5 "7/6/21 7:27" 1.9411757e+12 3 -5 "7/6/21 7:40" 1.9411765e+12 3 -5 "7/6/21 7:48" 1.941177e+12 3 -5 "7/6/21 7:51" 1.941177e+12 3 -5 "7/6/21 8:01" 1.9411776e+12 3 -5 "7/6/21 8:13" 1.9411784e+12 3 -5 "7/6/21 8:15" 1.9411785e+12 2 -6 "7/6/21 7:51" 1.941177e+12 3 -5 "7/6/21 8:08" 1.941178e+12 3 -5 "7/6/21 8:16" 1.9411785e+12 3 -5 "7/6/21 8:35" 1.9411797e+12 3 -5 "7/6/21 8:08" 1.941178e+12 5 -7 "7/6/21 8:38" 1.94118e+12 2 -6 "7/6/21 8:54" 1.9411808e+12 3 -5 "7/6/21 8:32" 1.9411795e+12 3 -5 "7/6/21 9:03" 1.9411814e+12 3 -5 "7/6/21 9:03" 1.9411814e+12 5 -7 "7/6/21 9:06" 1.9411816e+12 3 -5 "7/6/21 9:15" 1.941182e+12 3 -5 "7/6/21 9:06" 1.9411816e+12 2 -6 "7/6/21 9:22" 1.9411825e+12 2 -6 "7/6/21 9:21" 1.9411825e+12 2 -6 "7/6/21 9:21" 1.9411825e+12 3 -5 "7/6/21 9:33" 1.941183e+12 2 -6 "7/6/21 9:37" 1.9411834e+12 6 -8 "7/6/21 9:42" 1.9411837e+12 3 -5 "7/6/21 9:35" 1.9411833e+12 3 -5 "7/6/21 9:45" 1.941184e+12 3 -5 "7/6/21 9:41" 1.9411837e+12 3 -5 "7/6/21 9:54" 1.9411844e+12 3 -5 "7/6/21 9:49" 1.941184e+12 3 -5 "7/6/21 10:09" 1.9411854e+12 3 -5 "7/6/21 10:00" 1.941185e+12 3 -5 "7/6/21 10:10" 1.9411854e+12 2 -6 "7/6/21 10:22" 1.941186e+12 5 -7 "7/6/21 10:07" 1.9411852e+12 2 -6 "7/6/21 10:35" 1.941187e+12 3 -5 "7/6/21 10:42" 1.9411873e+12 6 -8 "7/6/21 10:40" 1.9411872e+12 2 -6 "7/6/21 10:54" 1.941188e+12 3 -5 "7/6/21 10:37" 1.941187e+12 3 -5 "7/6/21 11:03" 1.9411886e+12 3 -5 "7/6/21 10:58" 1.9411882e+12 3 -5 "7/6/21 11:08" 1.941189e+12 3 -5 "7/6/21 11:05" 1.9411886e+12 6 -8 "7/6/21 11:04" 1.9411886e+12 3 -5 "7/6/21 11:05" 1.9411886e+12 2 -6 "7/6/21 11:22" 1.9411897e+12 3 -5 "7/6/21 11:24" 1.94119e+12 2 -6 "7/6/21 11:43" 1.941191e+12 2 -6 "7/6/21 11:24" 1.94119e+12 2 -6 "7/6/21 11:35" 1.9411905e+12 5 -7 "7/6/21 11:00" 1.9411884e+12 3 -5 "7/6/21 11:35" 1.9411905e+12 3 -5 "7/6/21 11:37" 1.9411906e+12 6 -8 "7/6/21 11:45" 1.941191e+12 6 -8 "7/6/21 11:49" 1.9411914e+12 3 -5 "7/6/21 11:58" 1.941192e+12 6 -8 "7/6/21 12:03" 1.941192e+12 5 -7 "7/6/21 12:12" 1.9411927e+12 3 -5 "7/6/21 12:21" 1.9411932e+12 2 -6 "7/6/21 12:04" 1.941192e+12 3 -5 "7/6/21 12:32" 1.941194e+12 3 -5 "7/6/21 12:41" 1.9411944e+12 2 -6 "7/6/21 12:43" 1.9411945e+12 3 -5 "7/6/21 12:50" 1.941195e+12 3 -5 "7/6/21 12:54" 1.941195e+12 2 -6 "7/6/21 12:51" 1.941195e+12 3 -5 "7/6/21 13:02" 1.9411957e+12 2 -6 "7/6/21 13:14" 1.9411965e+12 3 -5 "7/6/21 13:09" 1.941196e+12 2 -6 end format %tc TOD label values timezone timezone label def timezone 2 "CST", modify label def timezone 3 "EST", modify label def timezone 5 "MST", modify label def timezone 6 "PST", modify
0 Response to How to generate a single time variable for survey respondents in different time zones?
Post a Comment