Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • calculating time spent on the survey

    Hi there,
    I have the following date and time variables. Based on these, how can I calculate the time (in seconds) that the respondent spent on the survey? Thank you in advance for your help.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int record double(start_date date)
    1217 2011206713999.9995 2011207744999.9998
    1227      2011207260000 2011207571000.0005
    1230 2011207322000.0007 2011208139999.9995
    1234 2011207424000.0007 2011207916999.9995
    1236 2011207655999.9995 2011208094000.0002
    1238 2011207847999.9993  2011208822999.999
    1239 2011207872999.9993 2011208545000.0005
    1241 2011208011000.0002 2011208577000.0005
    1248 2011208336999.9998  2011208866999.999
    1251 2011208494000.0007  2011208981999.999
    1259 2011209138000.0002 2011209752999.9988
    1260 2011209175000.0007 2011209807999.9998
    1264  2011209325999.999      2011210508000
    1267 2011209459999.9988  2011210079000.001
    1271 2011209854999.9988 2011210738999.9993
    1275 2011210031999.9993      2011210412000
    1276 2011210036999.9998  2011210824000.001
    1279 2011210101999.9993  2011210821999.999
    1280 2011210129000.0012 2011210634000.0005
    1283 2011210284000.0005 2011212004999.9998
    1284 2011210305999.9993 2011211036000.0002
    1285 2011210395999.9988 2011211049999.9995
    1288 2011210511000.0012  2011211244000.001
    1294  2011210764999.999 2011211386999.9998
    1296 2011210780000.0007  2011211136000.001
    1297 2011210786000.0007 2011212182999.9998
    1310      2011211234000 2011211742000.0005
    1314      2011211310000 2011213193000.0007
    1319 2011211540999.9993  2011212948999.999
    1321      2011211686000      2011212431000
    1327 2011211844000.0005  2011212496999.999
    1331 2011212098000.0007 2011212614000.0007
    1333  2011212161000.001  2011215508999.999
    1338 2011212399999.9995      2011212991000
    1341 2011212443999.9998 2011475516999.9993
    1342 2011212460000.0012 2011213138999.9995
    1343 2011212461000.0007  2011214587000.001
    1346 2011212498000.0012 2011213043999.9993
    1348 2011212577999.9998  2011213101999.999
    1349 2011212588000.0007 2011213006999.9988
    1351 2011212654999.9995 2011213327000.0007
    1353 2011212684000.0007 2011213439999.9988
    1356 2011212772000.0012 2011214093999.9995
    1357  2011212785000.001 2011213265999.9995
    1359  2011212855000.001 2011213188000.0002
    1360 2011212889999.9998  2011213855000.001
    1361 2011212894000.0007  2011213683000.001
    1363  2011212944000.001 2011213399999.9995
    1364 2011213017999.9995 2011213802999.9988
    1365 2011213068999.9995 2011470821000.0005
    1370  2011213088999.999 2011214028000.0005
    1378 2011213304999.9993 2011213952000.0002
    1381 2011213453000.0012      2.0112148e+12
    1382  2011213594000.001 2011214672000.0002
    1389 2011222110999.9998 2011222402000.0005
    1390 2011222122000.0002 2011222612000.0005
    1393 2011222161999.9995  2011222840000.001
    1395 2011222173000.0002 2011223626999.9995
    1400  2011222216000.001  2011222844999.999
    1409  2011222369000.001 2011224180999.9995
    end
    format %tc start_date
    format %tc date

  • #2
    I believe they are in millisecond, so just subtraction followed by dividing with 1000 should do:

    Code:
    gen timespent = (date - start_date)/1000

    Comment


    • #3
      Thank you so much Ken.

      Comment

      Working...
      X