SAS to the rescue: claiming your location on Google map by address only (without knowing latitude and longitude)



In June 2018 Google introduced changes to the way it handles its Maps platform. They now require API key in order to embed a map, plus Google Maps "projects" must now be associated with a billing account. Unless these new Google rules are met, Google maps described in the blog post will display with "For development purposes only" watermark but still retain its functionality.

Google Maps with SASIt is easy to claim a spot on Google Map when you know geographical coordinates of that location such as latitude and longitude. In my prior posts on the topic of using Google Maps with SAS, knowing the latitudes and longitudes of location was a requirement.

However, what if your data source does not contain those “pesky” latitude and longitude coordinates, but rather only good old postal addresses? Can you still get on Google map?

Handpicked Related Content: The power of SAS-generated InfoWindows in Google maps

The answer is: yes, you can place your location on Google Map using just postal address.

The solution is just one SAS proc away.

Here is an interactive example of several gas stations in the DC area that I placed on a Google map by their address only. Please take a minute to explore this interactive demo before reading further. Make sure to click on Google map markers to display additional information.

Interactive Google map generated in SAS

What is Geocoding?

Geocoding (sometimes called forward geocoding) is a function of converting a location’s description, such as place name or postal address, into geographic coordinates such as latitude and longitude. Reverse geocoding converts geographic coordinates – latitude and longitude - to a location’s description, usually a postal address or place name.

SAS’ geocoding procedure (yes, you guessed it, PROC GEOCODE ) produces geographic coordinate information for the following entities:

  • street addresses
  • cities
  • U.S. ZIP codes and ZIP+4 extension codes
  • foreign postal codes

The geographic coordinates typically represent the center of a ZIP code, a city or an address. So even if you don’t have compete postal address for your location, PROC GEOCODE will produce geographic coordinates for a center of a city or ZIP code.

In order to use street address to generate geographic coordinates, you must specify METHOD=STREET option for PROC GEOCODE (default METHOD is ZIP). Please note, that this method requires rather large lookup datasets which do not automatically installed with your SAS GRAPH software. For more information on the STREET geocoding method and to download necessary lookup data, see Understanding Street Geocoding.

How it is done

1.    I downloaded the US street-level file from the SAS Maps Online web page, unzipped it and imported the downloaded .csv files into SAS data tables using the SAS code that came with the zipped file. That SAS tables are used by the PROC GEOCODE as lookup tables.

2.     I created an initial data table with addresses for some gas station locations without latitude and longitude information. For simplicity, I used standard default variable names (address, city, state, zip) for locations so I didn’t have to specify them in the proc geocode optional arguments:

Table 1. Source Data (org_initial_info SAS dataset)

3.    Ran the following PROC GEOCODE:

/* Street lookup data library */
libname streetdl 'C:\PROJECTS\_BLOG_SAS\geocoding\StreetLookupData_94-2014\sasdata';
/* get geographic coordinates, Y=latitude, X=longitude */
proc geocode 
  data = work.org_initial_info
  out = work.org_info_geocoded
  method = street
  lookupstreet =streetdl.usm 

The output dataset org_info_ geocoded includes all the columns from the initial dataset org_initial_info plus the following additional columns (X is a longitude, Y is a latitude):

Table 2. Geocoded Data (org_info_geocoded SAS dataset)

At this point, our goal of placing multiple location on Google map is covered by my earlier blog post Live Google maps in SAS -- multiple markers. However, here I improved it a bit by using custom markers instead of generic ones. In order to do this, I created small marker images out of the companies’ logos with a transparent background. I saved these small images in the /images folder (relative to the final .html file location) and gave them names corresponding the company names with .png extension. Alternatively, I could have used additional column in the initial data table to specify marker file name.

To specify custom markers, you would need to add just one extra line ('icon: "images/' orgname +(-1) '.png",') in the marker definition, as shown below in the put statement code excerpt:

 'var marker' i '= new google.maps.Marker({' /
   'position: point' i ',' /
   'map: map,' /
   'icon: "images/' orgname +(-1) '.png",' /
   'title: "Click here for details"' /
'});' /

Click to view and download the full sample SAS code that include all the steps from creating an initial data table without geographic coordinates - latitude and longitude, proc geocode, determining coordinates of the map center, and generating an interactive Google map with custom markers.

Handpicked Related Content: The power of SAS-generated InfoWindows in Google maps


About Author

Leonid Batkhan

Leonid Batkhan is a long-time SAS consultant and blogger. Currently, he is a Lead Applications Developer at F.N.B. Corporation. He holds a Ph.D. in Computer Science and Automatic Control Systems and has been a SAS user for more than 25 years. From 1995 to 2021 he worked as a Data Management and Business Intelligence consultant at SAS Institute. During his career, Leonid has successfully implemented dozens of SAS applications and projects in various industries. All posts by Leonid Batkhan >>>


  1. How fun. I knew someone had a database of all the addresses in the U.S., but I didn't know SAS had them. Very nice.

    Do we have a database of elevations? I know we can find them online, but maybe there's some PROC ELEVATION that I haven't yet learned. 🙂

    • Leonid Batkhan

      Hi John,
      Thank you for your feedback. I am not sure if there is a SAS data set that has elevations of individual addresses, but there is a data set MAPSGFK.USCITY that has the altitude of cities. Take a look at this Alternate U.S. City Lookup Data. This data set MAPSGFK.USCITY is provided with SAS/GRAPH and it has 150,000+ US cities listed with their latitude, longitude as well as Altitude in meters (ALT_M) and Altitude in feet (ALT_FT) variables. Hope this helps.
      Best regards,

Leave A Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to Top