Dear SAS experts
I have a dataset containing coordinates for moving persons with a new latitude and longitude for every 10 seconds. The dataset also contains coordinates for their goal location. I would like to create a new column showing the time value when a person reaches the goal location (i.e. latitudeX and longitudeX match goal_latitude and goal_longitude, respectively). I consider the person to have arrived when he is within 0.0005 of goal coordinates.
goal_latitude | goal_longitude | new_column | time1 | latitude1 | longitude1 | time2 | latitude1 | longitude1 | ... | |
person1 | 55.7236 | 12.4472 | 2023-08-03T19:55:18.000+02:00 | 55.7215 | 12.4422 | 2023-08-03T19:55:28.000+02:00 | 55.7215 | 12.4424 | ||
person2 | 55.7234 | 12.4418 | 2023-08-03T19:55:01.000+02:00 | 55.7225 | 12.4368 | 2023-08-03T19:55:08.000+02:00 | 55.7226 | 12.4368 | ||
person3 | 55.7256 | 12.4435 | 2023-08-03T19:55:37.000+02:00 | 55.7247 | 12.4389 | 2023-08-03T19:55:38.000+02:00 | 55.7247 | 12.4389 |
Can this be done in SAS Enterprise Guide?
I have already tried with a very long CASE-statement:
CASE
WHEN (INPUT(t1.latitude1,8.))<(INPUT(t1.goal_latitude,8.) + 0.0005) AND (INPUT(t1.latitude1,8.))>((INPUT(t1.goal_longitude,8.) - 0.0005)) AND (INPUT(t1.longitude1,8.))<(INPUT(t1.goal_longitude,8.) + 0.0005) AND (INPUT(t1.longitude1,8.))>((INPUT(t1.longitude,8.) - 0.0005)) THEN (t1.time1)
...
ELSE 0
END
And I got this error message: "ERROR: Result of WHEN clause 2 is not the same data type as the preceding results."
Thank you for your help!
VictorK
Please provide your sample data and the desired outcome using this sample data via a working SAS data step that creates such data.
You have a much better chance of anyone actually providing tested code if we don't have to spend time creating such sample SAS datasets prior to actually creating the code you're after.
The dataset I'm working with is very large, but here are an example for one goal location.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.