Sample 50776: Using PROC GEOCODE to determine which ZIP codes are not valid for geo maps in SAS® Visual Analytics
In SAS Visual Analytics, you can use ZIP codes to display geo maps. If your data includes values that do not match the assigned geographical role US ZIP Codes, then you see a warning message. However, the unmatched ZIP codes are not identified.
This sample shows you how to use PROC GEOCODE to identify ZIP codes that do not match. The code creates a sample table for illustration. To use the code, replace the sample table with your own table. An example of the output is shown on the Output tab.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
/*------------------------------------------------------------+
| SAS MAPPING: Proc Geocode
| Purpose: Check for valid ZIP Codes
| NAME: Ck_ZIP_codes.sas
| SUMMARY: Geocode U.S. locations using ZIP method.
| RELEASE: SAS 9.2 - 9.4
| PRODUCT: GRAPH
+------------------------------------------------------------*/
/*------------------------------------------------------------+
| [ Address Data ]
| Create a small data set of U.S. addresses to geocode.
+------------------------------------------------------------*/
data customers (label='U.S. Customer addresses to geocode');
length address customer $24 city $16 state $2;
infile datalines dlm=',';
input customer zip revenue;
label
customer = 'Customer name'
zip = 'ZIP code'
revenue = 'Total revenue for customer';
format revenue dollar9.0; /* Show revenue in dollars */
datalines;
J. Cheever Loophole, 19901,985.33
Cuthbert J. Twillie, 19934, 2533.25
Kaspar Gutman, 19808, 1927, 33.44
Prof. Quincy Wagstaff, 19801, 1899.45
Hugo Z. Hackenbush, 19363, 987.02
Charlie Allnut, 19971, 2277, 1459.65
Larson E. Whipsnade, 19963, 4566.98
Guillermo Ugarte, 01000, 17.45
Capt. Geoffrey Spaulding, 19975, 1798.33
Joel Cairo, 19944, 2566.45
Charles Blutoski, 19953, 783.25
Fred C. Dobbs, 00000, 898.25
Rufus T. Firefly, ., 123.45
Otis B. Driftwood, 19955, 98.56
Gloria Teasdale, 21921, 661.13
Duke Mantee, 19980, 4531.87
;
run;
/*------------------------------------------------------------+
| [ Lookup Data ]
| The example uses SASHELP.ZIPCODE which is shipped with
| SAS and does not have to be installed separately.
| Quarterly updates to the ZIPCODE data set are available
| on MapsOnLine website: http://support.sas.com/MapsOnLine
+------------------------------------------------------------*/
/*------------------------------------------------------------+
| [ Proc GEOCODE ]
| Use the ZIP method to determine U.S. locations by ZIP code.
+------------------------------------------------------------+
| [ Notes ]
| 1. This uses the default lookup data set SASHELP.ZIPCODE
| as noted above.
| 2. Because the address and lookup data sets use default
| variable names, options such as ADDRESSCITYVAR=
| and LOOKUPCITYVAR= are not needed.
| 3. This example adds MSA and AREACODE values from the
| lookup dataset with the ATTRIBUTEVAR= option.
+------------------------------------------------------------*/
proc geocode
method = zip /* Geocoding method */
nocity /* Only check ZIP Codes */
data = work.customers /* Input address data */
out = work.geocoded /* Output data set */
addressZIPvar = zip /* Change if your varible not ZIP */
;
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Date Modified: | 2013-09-12 19:35:07 |
Date Created: | 2013-08-16 14:00:53 |
Operating System and Release Information
SAS System | SAS Visual Analytics | Microsoft® Windows® for x64 | 6.1 | | 9.3 TS1M2 | |
Linux for x64 | 6.1 | | 9.3 TS1M2 | |