Geocoding refers to the process of converting addresses or places names into geographic coordinates that can be plotted on a map. In SAS Viya, there are many ways to geocode data, including services from Esri and Loqate. However, both of these services charge a per-address cost, meaning that geocoding large volumes of data can get expensive. SAS also provides a geocoding procedure, called PROC GEOCODE. Unlike using Esri or Loqate services, PROC GEOCODE is free and performs the processing locally, without passing addresses back and forth to a third-party database. In this article, I will discuss how to access and configure the necessary lookup data sets to use the GEOCODE procedure in your own environment.
PROC GEOCODE relies on lookup data sets in your own SAS environment. In order to geocode US street addresses, six lookup data sets are required:
Together, these six data sets allow SAS to match street addresses to specific latitude and longitude coordinates. However, only the street state, street type, and street directional data sets are included by default with SAS, located in the SASHELP library. The street matching, street segment, and street coordinate data sets can be downloaded from the Maps and Geocoding SAS support website.
To access the download, click the Street Geocoding Downloads link on the Geocode Data page and sign in with your SAS profile.
Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.
This opens a list of all available geocode dataset downloads. US geocoding lookup datasets are based on US Census Bureau TIGER/Line shapefiles, meaning that they are generally updated once a year when new Census data becomes available.
Once you click on the desired year, you will be prompted to validate your site number.
You can find your site number in SAS Viya by clicking Profile in the top right and selecting About.
You can also find it by running PROC SETINIT in SAS Studio:
proc setinit;
run;
After you enter your site number, you’ll need to accept a license agreement before the download starts.
The lookup data download is provided as a ZIP file. The unzipped file contains 10 CSV files, a ReadMe, and a SAS program.
To create the three lookup SAS tables, you need to first move the unzipped files to a location accessible by SAS. Then, open the ImportCSVfiles.sas program and modify the PATHIN and PATHOUT macro variables. The PATHIN macro variable should point to the location where the CSV files have been stored, and PATHOUT should point to a location where the finished lookup tables will be stored.
Then, run the program. The code will import all 10 CSV files and combine them to create the three necessary geocoding tables, in a library called lookup. You only need to do this once, and then you can simply reference the lookup library as necessary when using PROC GEOCODE.
If you need lookup data beyond the prebuilt US geocoding lookup tables available for download, SAS also provides several programs that allow you to create lookup data from the original source. The Canadian NRN Import Code program and the Code To Import US TIGER files for 9.4 allow you to download Canadian National Road Network and Census Bureau TIGER/Line shapefiles and process them yourself.
PROC GEOCODE offers a powerful and cost-effective alternative to third-party geocoding services, allowing you to process addresses entirely within your own SAS environment. By downloading the necessary lookup data sets from the SAS support website and running the provided import program, you can quickly set up a fully functional geocoding pipeline. With support for both US and Canadian data and the flexibility to work with regional subsets, PROC GEOCODE is a practical solution for organizations looking to convert addresses into geographic coordinates at scale.
Find more articles from SAS Global Enablement and Learning here.
Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.
Explore Now →The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.