BookmarkSubscribeRSS Feed
Darkness_Falls
Calcite | Level 5

Say I have the following 4 houses with the distances between them

 

GHI 35ft ABC 20ft DEF 40ft JKL 100ft XYZ 10 ft WTH

 

Identifying each neighbor within 40ft is quite simple, however I want to identify each connected neighbor within 40 ft. So here GHI & JKL, ABC & JKL, etc. would all be neighbors as there is always less than or equal to 40 ft between them. XYZ would only be neighbors with WTH.

 

Essentially I would like the following resulting table

 

Location 1 - Neighbor 1 - Distance to Neighbor 1 - Neighbor 2 - Distance to Neighbor 2 - Neighbor 3 - Distance to Neighbor 3

ABC - DEF - 20ft - GHI - 35ft - JKL 40ft

DEF - ABC - 20ft - GHI - 35ft - JKL - 40ft

GHI - ABC -  35ft - DEF -  20ft - JKL - 40ft

JKL - DEF - 40ft - ABC - 20ft - GHI - 35 ft

XYZ - WTH - 10ft - - - -

WTH - XYZ - 10ft - - - -

 

 

Thanks in advance

3 REPLIES 3
PGStats
Opal | Level 21

You can't solve this problem with distances only, unless you have the distances between every house pairs. It is usually simpler to start with house locations. You can then locate every pair which is within 40ft and use SAS/OR OPTNET to find the connected components of houses within 40ft.

PG
Darkness_Falls
Calcite | Level 5
I do have the distances between each house pair (well the 100 closest houses to not have a massive dataset). How could I proceed with that info?

Sadly I do not have access to SAS/OR 😞
PGStats
Opal | Level 21

First, select all pairs closer than 40 ft apart, then use my macro at 

 

https://communities.sas.com/t5/General-SAS-Programming/Finding-all-connected-components-in-a-graph/m...

 

Good luck!

 

PG

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 471 views
  • 0 likes
  • 2 in conversation