You've got a database containing the addresses of all your customers ... but how can you plot them on a map or analyze them spatially? First, you'll need to convert the address into a numeric coordinate (latitude & longitude). SAS can do that ... with Proc Geocode!

But before we get into geocoding street addresses, here's a little diversion from my buddy (and Olympic gold winner) Joe Jacobi. Joe spends so much time on the water, that he probably doesn't even have a street address, LOL! So, how would you estimate a lat/long for him?!? ... Perhaps you could try a "wild guess"! Feel free to leave your wild guess of Joe's lat/long location in this photo in the comments section! :)

And now, on to Tip #6 - Geocoding your addresses!

First, you'll need to have your address data split up into separate variables, like the following. The data I'm using as an example is the address of SAS' headquarters. Note that the zip variable is numeric (not character):

Here's the code I used to create the data for my example, if you'd like to try running it as you follow along ...

length address \$50 city \$50 state \$2;
infile datalines dlm=',';
input address city state zip;
datalines;
100 SAS Campus Drive, Cary, NC, 27513
;
run;

Once your address data is stored in the desired format, all you have to do is run it through Proc Geocode. Note that in this simple example, I'm using the small lookup table for Wake county, NC, that we ship in the sashelp samples library. You'll want to download the full US lookupÂ table to use on your addresses - it is several GB in size, and can be downloaded from the SAS maps online page.

method=street lookupstreet=sashelp.geoexm;
run;

Once you run your address data through Proc Geocode, variables will be added for the latitude & longitude:

And now that you have the lat/long coordinates, you can do things like plot markers on a map. Here's a link to the complete code I used to geocode the data and plot it on the map.

Click here to see all my tips about mapping tools!

Share