BookmarkSubscribeRSS Feed
VictorK
Calcite | Level 5

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_latitudegoal_longitudenew_columntime1latitude1longitude1time2latitude1longitude1...
person155.723612.4472 2023-08-03T19:55:18.000+02:0055.721512.44222023-08-03T19:55:28.000+02:0055.721512.4424 
person255.723412.4418 2023-08-03T19:55:01.000+02:0055.722512.43682023-08-03T19:55:08.000+02:0055.722612.4368 
person355.725612.4435 2023-08-03T19:55:37.000+02:0055.724712.43892023-08-03T19:55:38.000+02:0055.724712.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

2 REPLIES 2
Patrick
Opal | Level 21

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.

VictorK
Calcite | Level 5

The dataset I'm working with is very large, but here are an example for one goal location.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1026 views
  • 0 likes
  • 2 in conversation