Hi @ballardw and @Reeza
Thanks for both of your answers. I have tried to make a datastep as requested:
data WORK.FAKE;
infile datalines dsd truncover;
input IncidentId:BEST12. IncidentTime:DATETIME18. AssignmentTime:DATETIME18. ConfirmedTime:DATETIME18. AcceptedTime:DATETIME18. incident_easting:$9. incident_northing:$9. _alias:$6. selected_time:$21. pos_easting:$9. pos_northing:$9. poi_id:$10. poi_eastin
g:$9. poi_northing:$9. notified_time:$29. closed_time:$29. pos_time_1:$29. pos_easting_1:$9. pos_northing_1:$9. pos_time_2:$29. pos_easting_2:$9. pos_northing_2:$9. pos_time_3:$29. pos_easting_3:$9. pos_northing_3:$9. pos_time_4:$29. pos_easting_4:$9. pos_
northing_4:$9. pos_time_5:$29. pos_easting_5:$9. pos_northing_5:$9. pos_time_6:$29. pos_easting_6:$9. pos_northing_6:$9. pos_time_7:$29. pos_easting_7:$10. pos_northing_7:$9.;
format IncidentId BEST12. IncidentTime DATETIME18. AssignmentTime DATETIME18. ConfirmedTime DATETIME18. AcceptedTime DATETIME18.;
datalines;
1064378 12FEB18:15:43:22 12FEB18:15:59:53 12FEB18:15:59:40 12FEB18:15:59:53 12.280186 55.626429 451245 2018-02-12 15:46:56.0 12.266320 55.610988 2018-02-12T15:46:56.000+01:00 2018-02-12T12:34:20.000+01:00 12.267114 55.611986
2018-02-12T12:34:20.000+01:00 12.269278 55.614381 2018-02-12T15:59:54.000+01:00 12.270823 55616077 2018-02-12T15:59:54.000+01:00 12.272192 55.617449 2018-02-12T15:59:54.000+01:00 12.274400 55.620118 2018-02-12T15:59:54.000+01:00 12.276432 55.622264
2018-02-12T16:01:26.000+01:00 12.278331 55.624359
1064378 12FEB18:15:43:22 12FEB18:15:47:19 12FEB18:15:47:17 12FEB18:15:47:20 12.280186 55.626429 745985 2018-02-12 15:46:56.0 12.318220 55.623781 2018-02-12T15:46:56.000+01:00 2018-02-12T15:58:16.000+01:00 2018-02-12T09:42:44.000+01:00 12.311948
55.625928 2018-02-12T15:47:16.000+01:00 12.304616 55.628223 2018-02-12T15:47:16.000+01:00 12.296400 55.630943 2018-02-12T15:47:21.000+01:00 12.285620 55.632489 2018-02-12T15:47:52.000+01:00 12.278861 55.624907 2018-02-12T15:48:19.000+01:00 12.278508
55.624558
1064378 12FEB18:15:43:22 12FEB18:15:47:20 12FEB18:15:47:14 12FEB18:15:47:20 12.280186 55.626429 785489 2018-02-12 15:46:56.0 12.265386 55.633611 1000009418 12.262428 55.627251 2018-02-12T15:46:56.000+01:00 2018-02-12T15:55:16.000+01:00
2018-02-12T09:46:25.000+01:00 12.265431 55.630718 2018-02-12T15:47:13.000+01:00 12.261898 55.627226 2018-02-12T15:47:13.000+01:00 12.257615 55.622935 2018-02-12T15:47:21.000+01:00 12.267510 55.622737 2018-02-12T15:47:58.000+01:00 12.278199 55.624434
2018-02-12T15:48:15.000+01:00 12.278773 55.624833
1064378 12FEB18:15:43:22 12FEB18:15:48:30 12FEB18:15:48:17 12FEB18:15:48:30 12.280186 55.626429 547845 2018-02-12 15:46:56.0 12.314328 55.616049 2018-02-12T15:46:57.000+01:00 2018-02-12T16:04:31.000+01:00 2018-02-12T15:30:30.000+01:00 12.320076
55.622383 2018-02-12T15:47:14.000+01:00 12.308370 55.623458 2018-02-12T15:48:17.000+01:00 12.290789 55.628274 2018-02-12T15:48:17.000+01:00 12.278729 55.624733
6 The SAS System 12:54 Friday, September 17, 2021
6326548 13FEB18:08:14:26 13FEB18:08:26:36 13FEB18:08:26:22 13FEB18:08:26:36 12.298998 55.929033 741014 2018-02-13 08:15:51.0 12.321744 55.927888 2018-02-13T08:15:53.000+01:00 2018-02-13T08:27:52.000+01:00 2018-02-12T18:37:57.000+01:00 12.325474
55.925710 2018-02-12T18:37:57.000+01:00 12.326471 55.920177 2018-02-13T08:26:37.000+01:00 12.320957 55.916881 2018-02-13T08:26:38.000+01:00 12.318909 55.919059 2018-02-13T08:27:09.000+01:00 12.312553 55.923355 2018-02-13T08:45:13.000+01:00 12.306773
55.927387 2018-02-13T08:45:13.000+01:00 12.299365 55.928975
;;;;
I hope it is correct? I have replaced all values with fake values. To ensure, that the calculations is correct, I have replaced all GPS stamps with real GPS stamps on real roads (got the GPS stamps from Google Maps). As mentioned, there can be up to around 63 GPS observations. However, in this fake dataset, I did only make up a maximum of 7 positions for each observation.
I tried the code:
data mydata;
set mydata;
array pe (*) Pos_easting: ;
array pn (*) Pos_northing: ;
array d (63);
do i= 1 to ( dim(pe) -1);
d[i] = geodist(pn[i],pe[i],pn[i+1],pe[i+1]);
*distance to event;
d2event = geodist(pn[i], pe[i], incident_northing, incident_easting);
*exit out of array loop once closes distance to event is found;
if d2event < 25 then leave;
end;
cumd = sum(of d(*));
run;
It runs without any errors. But my output data does not seem correct. I get several new variables (d1-d60) but most with missing values (value = .) except d1. However, d1 is often 0 which cumd also is (because of all the missing or the fact that d1=0, I guess).
I hope that it is more clear with the above information. Thanks once again!
/MM
... View more