BookmarkSubscribeRSS Feed
kumarK
Quartz | Level 8

Removed because of violation of company policy

5 REPLIES 5
art297
Opal | Level 21

You have to be more specific with your question. Do you want to find, say, the ten zip codes from file2 that are closest to the zip codes identified in each of file1's records?

Patrick
Opal | Level 21

So if I understand right you want to assign a Zip code to the Senior Executive with minimal summed up distance to the Executives.

To determine this Zip code: Does it need to be one of the Zip codes of the Executives or should it be another Zip code "in the center" of all the Executives.

Reeza
Super User

A GIS software is better at this than SAS, but it's doable in SAS.

ZIP codes represent area's though they're represented by the centroid latitude and longitude most of the time. You can create a distance table of the ZIP to ZIP code (40thousand rows*40 thousand Columns) or a table with ZIP1, ZIP2, Distance which would be 1.6Billion rows.  You could simplify this by deleting distances over 1000 KM or so, or some other rule that makes business sense. 

Then you can loop and assign an area for each executive, defining rules for overlaps. The rules may need to be different in rural vs urban areas.

There's probably a more efficient way of doing this - for example if it was Canada, I know all the Postal Codes starting with T belong to Alberta, and T0 is an rural area. I'm not sure if the ZIP code has such a structure. Also, there may be more efficient ways of programming this - hopefully someone smarter than me chimes in Smiley Happy

In a GIS software such as ArcGIS or QGIS this is as simple as selecting nearest neighbours within a specific distance and then making sure you have no overlaps - much easier Smiley Wink

jakarman
Barite | Level 11

There is a geodist function SAS(R) 9.4 Functions and CALL Routines: Reference, Third Edition  Remember it is physical direct distance line, NOT the distance by travelling hours.

How many senior executive you have 100 100? small enough the be a column representation?

---->-- ja karman --<-----
jakarman
Barite | Level 11

Kumar, Now the problem is becoming interesting. You can cluster your zipcodes in the number you are needing by nearest distance and than map the executives on that or you have some fixed locations for those executives and than trying to map zip to them. It is all on the soft and hard specs en reqs with the goals behind those.
There must be a lot of publications on the more theoretical parts. There will be often not a best solutions but many times an acceptable one (time/effort change/situation)  

---->-- ja karman --<-----

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
  • 5 replies
  • 1095 views
  • 2 likes
  • 5 in conversation