09-17-2021
Mikkel_madsen
Obsidian | Level 7
Member since
04-20-2020
- 36 Posts
- 14 Likes Given
- 0 Solutions
- 1 Likes Received
-
Latest posts by Mikkel_madsen
Subject Views Posted 1193 09-17-2021 07:14 AM 1273 09-15-2021 05:36 AM 1433 09-14-2021 03:19 AM 501 09-09-2021 03:30 AM 606 09-08-2021 07:18 AM 7023 03-11-2021 03:24 AM 7177 03-10-2021 01:55 PM 3831 01-07-2021 03:51 AM 1201 01-06-2021 05:42 AM 1205 01-06-2021 05:32 AM -
Activity Feed for Mikkel_madsen
- Posted Re: Calculation of distance based on GPS-stamps on SAS Programming. 09-17-2021 07:14 AM
- Posted Re: Calculation of distance based on GPS-stamps on SAS Programming. 09-15-2021 05:36 AM
- Posted Calculation of distance based on GPS-stamps on SAS Programming. 09-14-2021 03:19 AM
- Posted Re: Calculation of distance and traveltime with multiple GPS points on SAS Programming. 09-09-2021 03:30 AM
- Posted Calculation of distance and traveltime with multiple GPS points on SAS Programming. 09-08-2021 07:18 AM
- Posted Re: Change dot to comma on SAS Programming. 03-11-2021 03:24 AM
- Liked Re: Change dot to comma for Cynthia_sas. 03-11-2021 03:24 AM
- Posted Change dot to comma on SAS Programming. 03-10-2021 01:55 PM
- Posted add text to a variable on SAS Programming. 01-07-2021 03:51 AM
- Posted Re: Search and create column on SAS Programming. 01-06-2021 05:42 AM
- Posted Re: Search and create column on SAS Programming. 01-06-2021 05:32 AM
- Posted Re: Search and create column on SAS Programming. 01-06-2021 04:58 AM
- Posted Re: Search and create column on SAS Programming. 01-06-2021 04:47 AM
- Posted Search and create column on SAS Programming. 01-06-2021 04:22 AM
- Posted Sort data on SAS Programming. 11-12-2020 02:12 PM
- Posted Re: combine rows on SAS Programming. 08-27-2020 05:42 AM
- Liked Re: combine rows for PeterClemmensen. 08-27-2020 05:42 AM
- Posted combine rows on SAS Programming. 08-27-2020 04:54 AM
- Posted Re: Create new variable on New SAS User. 08-25-2020 08:35 AM
- Liked Re: Create new variable for Kurt_Bremser. 08-25-2020 08:31 AM
-
Posts I Liked
Subject Likes Author Latest Post 1 1 1 1 1 -
My Liked Posts
Subject Likes Posted 1 07-03-2020 05:29 AM
09-17-2021
07:14 AM
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
09-15-2021
05:36 AM
Hi @Reeza and @ballardw,
Thanks for your time. I tried my best to explain it, I am sorry if it was unclear.
It was just an example with the baker, to make it easier to explain and understand. The data is highly sensitive. I tried to make a data-step as requested, however, it would be several hundred values I had to re-arrange. Further, to test it in the right way you would need reel GPS-stamps on a given road.
Every observation can have several (more than 2 and up to around 60) GPS-stamps from pos_east and pos_north to event_east and event_north. I labelled the travelling positions wrong, they are called "pos_east_1, pos_east_2 and so on). If I understand it correctly, the method @Reeza describes in code does calculate the distance from pos_east to pos_east_1 and from pos_east_1 to pos_east_2 and finally sum the different distances. The first position within 25 meters from the event_east and event_north should be used as the last (I believe it is also done in the code). Unfortunately, the code does not seem to work. Maybe it is because of the wrong labelling?
Further, most observations goes by poi_east and poi_north on its way to event_east and event_north. Can this be taken in to account? So those observations without and poi-coordinates are done as first described, but those with poi-coordinates will first have the distance from pos_east and pos_north to poi-coordinates calculated and then again from poi-coordinates to event-coordinates?
I know I must sound like a giant newbie which is also what I am. I am very grateful for your spare full time and a huge help! Sorry for my incompetence.
... View more
09-14-2021
03:19 AM
Hi everyone,
I have a rather complicated task which I would love your input on. It consists of several tasks/ issues. Overall, the data look similar to this (beware: these data are fake and is only an example):
ID
Event_time
Event_east
Event_north
Poi_east
Poi_north
Notify_time
Pos_east
Pos_north
Pos_time1
Pos_east1
Pos_north1
Pos_time2
Pos_east2
Pos_north2
Pos_time3
Pos_east3
Pos_north3
1
11Feb2021:18:08:02
12.134963
55.461058
12.451788
55.421875
2021-02-11T18:09:55.000+01:00
12.124598
55.457985
2021-02-11T18:10:55.000+01:00
12.561334
55.876498
2021-02-11T18:11:55.000+01:00
12.457935
55.215469
2021-02-11T18:10:57.000+01:00
12.457896
55.897569
2
12Feb2021:16:12:00
12.457965
55.589512
12.021369
55.021369
2021-02-12T16:12:55.000+01:00
12.146026
55.012459
2021-02-12T16:12:56.000+01:00
12.012459
55.124598
2021-02-12T16:12:57.000+01:00
12.215498
55.124023
2021-02-12T16:12:58.000+01:00
12.459065
55.213026
I have several GPS- and timestamps (up to e.g. Pos_time60 and Pos_east60 etc). The different positions (pos_eastn and pos_northn may represent a route of a biker).
I want to:
1) Calculate the true-line distance from pos_east and pos_north (e.g. a biker's starting position) to event_east and event_north (the event). As I have several GPS stamps from 'the biker' (up to >60) I believe it could be done by straight-line calculation from pos_east to pos_east1 to pos_east2 to pos_eastn.... to event_east (the event). However, some of the last GPS-stamps from 'the biker' may be relatively close to the event GPS position. Therefore, the first position of 'the biker' within 25 meters from event_east and event_north should be used as the final position (if it makes any sense).
I do not know how to incorporate all this in the geodist function.
Thanks!
All best
/MM
... View more
09-09-2021
03:30 AM
Hi @Ksharp,
Thanks, I did that prior to my post without any luck.
... View more
09-08-2021
07:18 AM
Hi everyone,
I have a rather complicated task which I would love your input on. It consists of several tasks/ issues. Overall, the data look similar to this (beware: these data are fake and i only an example):
ID
Event_time
Event_east
Event_north
Poi_east
Poi_north
Notify_time
Pos_east
Pos_north
Pos_time1
Pos_east1
Pos_north1
Pos_time2
Pos_east2
Pos_north2
Pos_time3
Pos_east3
Pos_north3
1
11Feb2021:18:08:02
12.134963
55.461058
12.451788
55.421875
2021-02-11T18:09:55.000+01:00
12.124598
55.457985
2021-02-11T18:10:55.000+01:00
12.561334
55.876498
2021-02-11T18:11:55.000+01:00
12.457935
55.215469
2021-02-11T18:10:57.000+01:00
12.457896
55.897569
2
12Feb2021:16:12:00
12.457965
55.589512
12.021369
55.021369
2021-02-12T16:12:55.000+01:00
12.146026
55.012459
2021-02-12T16:12:56.000+01:00
12.012459
55.124598
2021-02-12T16:12:57.000+01:00
12.215498
55.124023
2021-02-12T16:12:58.000+01:00
12.459065
55.213026
This is just an example. I have several GPS- and time stamps (up to e.g. Pos_time60 and Pos_east60 etc). The different positions (pos_eastn and pos_northn may represent a biker).
I want to:
1) Calculate the true-line distance from pos_east and pos_north (e.g. a bikers starting position) to event_east and event_north (the event). As I have several GPS stamps from 'the biker' (up to >60) I believe it could be done by straight-line calculation from pos_east to pos_east1 to pos_east2 to pos_eastn.... to event_east (the event). However, some of the last GPS-stamps from 'the biker' may be relatively close to the event GPS position. Therefore, the first position of 'the biker' within 25 meters from event_east and event_north should be used as the final position (if it makes any sense).
2) I want to calculate the travel time of 'the biker' from notify_time until the first position within 25 meters from the event_east and event_north. The variable pos_timen represents the time 'the biker' was at pos_eastn and pos_northn.
3) Some 'bikers' travels via poi_east and poi_north before going to event_east and event_north. I want to first calculate the distance from pos_east and pos_north to poi_east and poi_north (again via pos_eastn and pos_northn - and also with the first GPS-stamp within 25 meters from poi_east and poi_north) and secondly the distance from poi_east and poi_north till event_east and event_north (again via pos_eastn and pos_northn - and also with the first GPS-stamp within 25 meters from poi_east and poi_north).
4) As in task 2, I want to calculate the traveltime of 'the biker' from the original position (pos_east and pos_north) until 25 meters within the poi_east and poi_north and again from poi-coordinates until within 25 meters from the event-coordinates.
Sorry for all the text! It is rather complicated! I hope it makes sense.
Thanks in advance!
All best
MM
... View more
03-11-2021
03:24 AM
Thank you, everyone!
I need to replace the dot with a comma before import to QGIS for geo-analysis.
... View more
03-10-2021
01:55 PM
Hi,
I have a dataset with some GPS positions including a dot which I want to change to a comma.
An example of the data is:
X Y
45.12542 12.07830
45.58219 11.98459
I have tried:
data want;
set have;
X=translate(X,'.',',');
Y=translate(Y,'.',',');
run;
But it only returns "missing" values, so all coordinates disappear. Both variables are of course numeric.
Thanks in advance!
All best
MM
... View more
01-07-2021
03:51 AM
Hi,
I have a question (probably an easy one).
How can I add text to a variable? It looks like:
ID
27693057
20377519
31679420
02310259
02148619
Can I have them to look like these:
ID
DM-27693057
DM-20377519
DM-31679420
DM-02310259
DM-02148619
A solution could also be to remove the 'DM-' part as I want to join two datasets. The numbers in each ID is identical, but I cant join them right now because of the 'DM-' part. The first variables (only numbers) is in format BEST12. while the variables with DM- is in the format $CHAR12.
Thank you!
/MM
... View more
01-06-2021
05:32 AM
b_9601 is yyww (year and week). I tried changing yymmn4 to yywwn4, but get error when I do this.
... View more
01-06-2021
04:47 AM
I am not sure what you mean by character columns, sorry.
The value to be searched for are four different combinations of a 3-digit number (123, 000, 100, and 110).
... View more
01-06-2021
04:22 AM
Hi,
Happy new year!
I got multiple columns named “b_yyww” specifying the year and week, eg. b_0003 and b_9751. The columns are arranged in order b_9601 to b_1352.
I have another column “date of event” specifying the date of at given event (ddmmyy).
I want to search for a specific value “123” in the “b_yyww” columns and create two new columns: “123 before event” and “123 after event” specifying whether 123 occurred before/after the event “yes”/”no”.
Is this possible?
/MM
... View more
11-12-2020
02:12 PM
Hi,
I have the following dataset:
RECNR OPR
123 XDFW
123 EDG03
1245 XDFW
1245 EDG03
1245 KFE011
1245 RTF00
So I have several observations with equal RECNR but different OPR value.
I want to keep observations with equal RECNR (e.g. 1245) that have the OPR values of EDG03 AND XDFW.
Can anyone help?
Thanks a lot!
... View more