Dear all,
I would like to know if my variable -ser_blue_tariffs- is well coded. To verify that, it should be true that for each individual that has taken more than one trip, this variable takes value of 0 if the arrival time of the previous trip was 8pm (up to 9pm), and departure time of the current trip should be between 8pm and 9pm also.
Here is what I coded, but not sure of it at all:
I am using -browse- to check it "manually". Surely, there are better ways to do that, and I would like to know how please.
Here's what I've coded to check. However it takes a long time to visually check some of the inconsistencies.
A small dataex:
Suggestions would be most welcome.
Thank you.
Best,
Michael
I would like to know if my variable -ser_blue_tariffs- is well coded. To verify that, it should be true that for each individual that has taken more than one trip, this variable takes value of 0 if the arrival time of the previous trip was 8pm (up to 9pm), and departure time of the current trip should be between 8pm and 9pm also.
Here is what I coded, but not sure of it at all:
Code:
* if individual lives in a given barrio (ser_regulado_free), parking costs = 0 if 8pm-9pm gen eight_pm = clock("20:00:00", "hms") gen nine_pm = clock("21:00:00", "hms") format %tC eight_pm nine_pm by individ_ID (start_time), sort: gen actual_start_time = start_time if _n > 1 format %tC actual_start_time forval i = 2/`=_N' { if actual_start_time[`i'] < nine_pm & end_time[`i'-1] > eight_pm { replace ser_blue_tariffs = 0 if !missing(blue_slots[`i'-1]) in `i' } } drop eight_pm actual_start_time nine_pm
I am using -browse- to check it "manually". Surely, there are better ways to do that, and I would like to know how please.
Here's what I've coded to check. However it takes a long time to visually check some of the inconsistencies.
Code:
browse if (inrange(end_hour[_n-1],20,21) & inrange(start_hour,20,21) & ID_VIAJE >1)
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str9 individ_ID byte ID_VIAJE double(start_time end_time) float interlude double ser_blue_tariffs "1000154_1" 1 59400000 60300000 . . "1000154_1" 2 79200000 81000000 315 . "1000154_2" 1 64800000 66600000 . . "1000154_2" 2 79200000 81000000 210 . "1000289_1" 1 28800000 30600000 . . end format %tC start_time format %tC end_time
Thank you.
Best,
Michael
Comment