Previous Page | Next Page

The GEOCODE Procedure

Example 2: Adding Additional Variables to the Output Data Set


Procedure features:

ATTRIBUTEVAR=, DATA=, OUT=

Sample library member: GEOVARS

The following example illustrates using the ATTRIBUTEVAR= option to add additional variables (from the lookup data set) to the output data set. The example also illustrates using the DATA= option to specify an input address data set.

 Note about code
data CUSTOMERS (label="Customer data for geocoding");
infile datalines dlm='#';
   length address $ 24 city $ 24 state $ 2;
   input address  /* House number and street name */
         zip      /* Customer ZIP code (numeric)  */
         city     /* City name                    */
         state    /* Two-character postal code    */   ;
   cust_ID = _n_;   /* Assign customer ID number    */
datalines;
555 Junk Street # 99999 # Beverly Hills # CA
115 E. Water St # 19901 # Dover #
760 Moose Lodge Road # 19934 # Camden #
200 S. Madison Str # 19801 # Wilmington # DE
4701 Limestone Road # 19808 # Wilmington #
2117 N 4th St # 19363 # Oxford # PA
1313 Mockingbird Lane # . # Delray # CC
133 Silver Lake Dr # 19971 # Rehoboth Beach # DE
11 SE Front Street # 19963 # Milford # DE
402 Nylon Boulevard # . # Seaford # DE
363 E Commerce St # . # Smyrna # DE
5595 Polly Branch Rd # 19975 # Selbyville # DE
1209 Coastal Highway # 19944 # Fenwick Island # DE
2899 Arthursville Rd # 19953 # Hartly # DE
41 Bramhall St # . #  #
9320 Old Racetrack Rd # . # Delmar # DE
281 W Commerce Str # 19955 # Kenton #
211 Blue Ball Road # 21921 # Elkton # MD
3893 Turkey Point Rd # 19980 # Woodside # DE
;
 Note about code
proc geocode method=ZIP                          /* Geocoding method        */
             data=customers                      /* Address data            */
             out=geocoded_customers              /* Output data set         */
             attributevar=(statename, countynm); /* Include these variables */
run;

proc print data=geocoded_customers noobs;
  var x y _matched_ statename countynm address zip;
run;

The following output from PROC PRINT shows the output data set after running the GEOCODE procedure. Notice that the following variables have been added to the output data set:

The attribute variables STATENAME and COUNTYNM are missing where the value for _MATCHED_ is "None." The attribute variables are also missing where _MATCHED_ is "City mean"--these observations were matched with multiple city-and-state observations in the lookup data set, so the correct values for the attribute variables cannot be determined.

The GEOCODED_CUSTOMERS Data Set with Additional Variables

    X       Y    _MATCHED_ STATENAME    COUNTYNM   address                zip

-118.398 34.0695 City mean                         555 Junk Street       99999
 -75.532 39.1500 ZIP       Delaware     Kent       115 E. Water St       19901
 -75.570 39.0953 ZIP       Delaware     Kent       760 Moose Lodge Road  19934
 -75.549 39.7366 ZIP       Delaware     New Castle 200 S. Madison Str    19801
 -75.669 39.7317 ZIP       Delaware     New Castle 4701 Limestone Road   19808
 -75.961 39.7877 ZIP       Pennsylvania Chester    2117 N 4th St         19363
    .      .     None                              1313 Mockingbird Lane     .
 -75.081 38.7265 ZIP       Delaware     Sussex     133 Silver Lake Dr    19971
 -75.432 38.9035 ZIP       Delaware     Sussex     11 SE Front Street    19963
 -75.611 38.6387 City      Delaware     Sussex     402 Nylon Boulevard       .
 -75.606 39.2912 City      Delaware     Kent       363 E Commerce St         .
 -75.150 38.4663 ZIP       Delaware     Sussex     5595 Polly Branch Rd  19975
 -75.053 38.4593 ZIP       Delaware     Sussex     1209 Coastal Highway  19944
 -75.693 39.1509 ZIP       Delaware     Kent       2899 Arthursville Rd  19953
    .      .     None                              41 Bramhall St            .
 -75.574 38.4557 City      Delaware     Sussex     9320 Old Racetrack Rd     .
 -75.666 39.2282 ZIP       Delaware     Kent       281 W Commerce Str    19955
 -75.850 39.6264 ZIP       Maryland     Cecil      211 Blue Ball Road    21921
 -75.567 39.0695 ZIP       Delaware     Kent       3893 Turkey Point Rd  19980

Previous Page | Next Page | Top of Page