Hi everyone,
I want to create a variable in minutes, from two variables in date %tC format. In fact, for each -individ_ID- I want to calculate the difference between the arrival time of the 1st trip (end_time) and the departure time of the second trip (start_time). Then the time difference between the arrival time of the second trip if it exists (end_time) and the departure time of the 3rd trip (start_time), etc.
The journey variable corresponds to -ID_VIAJE- and 1 means 1st journey, 2 means 2nd journey and so on. Below is an example of my dataset.
Could someone please help me solve this problem?
Thank you in advance.
Best,
Michael
I want to create a variable in minutes, from two variables in date %tC format. In fact, for each -individ_ID- I want to calculate the difference between the arrival time of the 1st trip (end_time) and the departure time of the second trip (start_time). Then the time difference between the arrival time of the second trip if it exists (end_time) and the departure time of the 3rd trip (start_time), etc.
The journey variable corresponds to -ID_VIAJE- and 1 means 1st journey, 2 means 2nd journey and so on. Below is an example of my dataset.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str9 individ_ID long ID_HOGAR byte ID_VIAJE double(start_time end_time) "189_1" 189 2 64800000 66600000 "189_1" 189 1 28800000 30600000 "244_2" 244 1 40380000 40500000 "244_1" 244 1 28800000 30000000 "244_1" 244 2 64800000 66000000 "244_2" 244 2 44280000 44400000 "324_1" 324 1 40620000 40800000 "324_1" 324 2 47520000 47700000 "414_1" 414 2 47940000 48000000 "414_3" 414 1 31260000 31500000 "414_2" 414 1 42960000 43200000 "414_1" 414 1 39540000 39600000 "414_3" 414 2 61860000 62100000 "414_3" 414 3 68400000 69600000 "414_2" 414 2 46560000 46800000 "581_3" 581 1 32160000 32400000 "581_2" 581 2 54000000 55800000 "581_1" 581 1 25200000 25500000 "581_4" 581 2 57600000 58500000 "581_4" 581 1 30600000 32400000 "581_3" 581 2 58260000 58500000 "581_2" 581 1 28800000 30600000 "742_1" 742 1 25200000 28800000 "742_2" 742 2 61200000 66000000 "742_1" 742 2 57600000 60300000 "742_2" 742 1 28800000 34200000 "759_3" 759 2 51300000 54000000 "759_1" 759 4 53100000 54600000 "759_2" 759 2 64800000 70200000 "759_4" 759 2 53100000 54000000 "759_2" 759 1 24300000 28800000 "759_3" 759 1 27000000 29700000 "759_1" 759 1 27600000 28800000 "759_4" 759 1 27900000 28800000 "759_1" 759 3 52380000 53100000 "759_1" 759 2 28800000 29700000 "914_2" 914 1 28800000 29700000 "914_1" 914 2 46800000 48000000 "914_2" 914 2 64800000 66000000 "914_1" 914 1 39600000 40500000 "1096_2" 1096 5 50760000 51000000 "1096_1" 1096 1 27600000 28800000 "1096_1" 1096 2 54000000 57600000 "1096_2" 1096 2 32820000 33300000 "1096_2" 1096 4 49740000 50400000 "1096_2" 1096 3 43140000 43200000 "1096_3" 1096 1 31860000 32400000 "1096_3" 1096 2 50400000 51000000 "1096_2" 1096 1 32220000 32400000 "1479_2" 1479 1 27000000 29700000 "1479_1" 1479 1 29520000 29700000 "1479_1" 1479 4 61200000 61800000 "1479_1" 1479 3 57600000 61200000 "1479_3" 1479 2 52020000 52200000 "1479_2" 1479 2 51300000 54000000 "1479_1" 1479 2 29700000 32400000 "1479_3" 1479 1 29520000 29700000 "1508_2" 1508 1 33300000 34800000 "1508_2" 1508 2 61200000 63000000 "1508_1" 1508 2 64800000 66600000 "1508_1" 1508 1 28800000 31200000 "1710_3" 1710 1 50040000 50400000 "1710_3" 1710 2 61200000 62460000 "1710_1" 1710 2 34560000 35760000 "1710_2" 1710 2 68400000 73200000 "1710_2" 1710 1 28800000 31500000 "1710_4" 1710 2 56340000 56700000 "1710_3" 1710 3 72000000 72300000 "1710_1" 1710 1 30600000 34200000 "1710_4" 1710 1 53640000 54000000 "1710_1" 1710 3 63000000 66900000 "2275_3" 2275 1 29460000 30600000 "2275_2" 2275 1 29460000 30000000 "2322_5" 2322 1 51120000 57600000 "2322_1" 2322 1 31200000 36000000 "2322_3" 2322 1 51120000 57600000 "2332_1" 2332 4 78300000 81000000 "2332_1" 2332 5 82800000 84300000 "2332_1" 2332 2 64800000 67500000 "2332_1" 2332 1 25200000 29400000 "2502_2" 2502 2 66600000 69300000 "2502_3" 2502 2 50400000 55200000 "2502_2" 2502 1 21600000 23400000 "2502_3" 2502 1 23400000 27000000 "2882_2" 2882 1 52920000 59400000 "3216_5" 3216 2 73800000 79200000 "3216_2" 3216 2 66600000 72000000 "3216_3" 3216 3 70200000 72000000 "3216_1" 3216 1 23100000 27600000 "3216_1" 3216 3 68400000 70200000 "3216_5" 3216 1 52200000 56100000 "3216_1" 3216 2 50400000 54900000 "3216_4" 3216 1 37800000 45000000 "3216_3" 3216 1 37800000 45000000 "3216_2" 3216 1 36000000 41400000 "3216_4" 3216 2 62160000 69300000 "3216_3" 3216 2 63000000 69300000 "3230_1" 3230 4 68400000 70200000 "3230_1" 3230 2 38700000 42300000 "3230_1" 3230 1 36000000 37800000 end format %tC start_time format %tC end_time
Thank you in advance.
Best,
Michael
Comment