GEOCODE Procedure

Example 2: Street Geocoding

Features:

STREET geocoding method

Procedure Options:
METHOD=
DATA=
OUT=
LOOKUPSTREET=
ATTRIBUTEVAR=
Other features:
Base SAS functions:
SAS DATA step
PRINT procedure
Data set: SASHELP.GEOEXM (primary street lookup data set
Sample library member: GEOSTRT
This example illustrates the STREET geocoding method to obtain coordinates based on street addresses with house numbers. The ATTRIBUTEVAR= option specifies an additional variable to include in the output data set.

Output

The following output from the PRINT procedure shows the output data set after running the GEOCODE procedure. In addition to the default output variables, the TRACTCE00 attribute variable was added to assign the Census Tract value for each geocoded location.
The following output from the PRINT procedure shows the WORK.GEOCODED output data set after running the GEOCODE procedure
The WORK.GEOCODED Data Set with STREET Method Output Variables
The WORK.GEOCODED Data Set with STREET Method Output Variables

Program

data WORK.CUSTOMERS (label='Input data for street geocoding');
  infile datalines dlm='#';
    length address $ 32
           city    $ 24
           state   $ 2;
   input address  /* House number and street name */
         zip      /* Customer ZIP code (numeric)  */
         city     /* City name                    */
         state;   /* Two-character postal code    */
datalines;
555 Junk Street # 99999 # Beverly Hills # CA
305 Cross Lake Drive # 27526 # Fuquay-Varina # NC
2525 Banks Road # 27603 # Raleigh # NC
2222 SAS Campus Drive # 27513 # Cary # NC
1150 SE Maynard Rd. # 27511 # Cary # NC
2117 Graceland # 27606 # Raleigh # NC
1313 Mockingbird Lane # # Delray # CC
133 Jade Circle # 27545 # Knightdale # NC
1005 W South St # 27603 # Raleigh # NC
N Winds North Drive # 27591 # Wendell # NC
622 Roundabout Road # 27540 # Holly Springs # NC
Johnson Family Rd # 27526 # #
822 Water Plant Road # # Zebulon # NC
502 Possum Track Road # 27614 # # NC
2590 Wolfpack Lane # 27604 # Raleigh # NC
125 Ferris Wheel Ct # 27513 # Cary # NC
;
run;
proc geocode                           /* Invoke geocoding procedure       */
   method=STREET                       /* Specify geocoding method         */
   data=WORK.CUSTOMERS                 /* Input data set of addresses      */
   out=WORK.GEOCODED                   /* Output data set with X/Y values  */
   lookupstreet=SASHELP.GEOEXM         /* Primary street lookup data set   */
   attributevar=(TRACTCE00);           /* Assign Census Tract to locations */
run;
proc print data=WORK.GEOCODED noobs;
   var address m_addr m_zip m_obs _matched_ _status_  _notes_ _score_ x y tractce00;
run;
quit;

Program Description

Generate the WORK_CUSTOMERS input data set of addresses that the GEOCODE procedure will use.
data WORK.CUSTOMERS (label='Input data for street geocoding');
  infile datalines dlm='#';
    length address $ 32
           city    $ 24
           state   $ 2;
   input address  /* House number and street name */
         zip      /* Customer ZIP code (numeric)  */
         city     /* City name                    */
         state;   /* Two-character postal code    */
datalines;
555 Junk Street # 99999 # Beverly Hills # CA
305 Cross Lake Drive # 27526 # Fuquay-Varina # NC
2525 Banks Road # 27603 # Raleigh # NC
2222 SAS Campus Drive # 27513 # Cary # NC
1150 SE Maynard Rd. # 27511 # Cary # NC
2117 Graceland # 27606 # Raleigh # NC
1313 Mockingbird Lane # # Delray # CC
133 Jade Circle # 27545 # Knightdale # NC
1005 W South St # 27603 # Raleigh # NC
N Winds North Drive # 27591 # Wendell # NC
622 Roundabout Road # 27540 # Holly Springs # NC
Johnson Family Rd # 27526 # #
822 Water Plant Road # # Zebulon # NC
502 Possum Track Road # 27614 # # NC
2590 Wolfpack Lane # 27604 # Raleigh # NC
125 Ferris Wheel Ct # 27513 # Cary # NC
;
run;
Run the GEOCODE procedure with the generated input data set.
proc geocode                           /* Invoke geocoding procedure       */
   method=STREET                       /* Specify geocoding method         */
   data=WORK.CUSTOMERS                 /* Input data set of addresses      */
   out=WORK.GEOCODED                   /* Output data set with X/Y values  */
   lookupstreet=SASHELP.GEOEXM         /* Primary street lookup data set   */
   attributevar=(TRACTCE00);           /* Assign Census Tract to locations */
run;
Print the specified variable values from the WORK_GEOCODED output data set, suppressing the observation column.
proc print data=WORK.GEOCODED noobs;
   var address m_addr m_zip m_obs _matched_ _status_  _notes_ _score_ x y tractce00;
run;
quit;