ZIP code to city name conversion information


Beginning with SAS 9.1 TS Level 1M3 (SAS 9.1.3), the ZIPCITY function
can be used to obtain the name of the city for a specific ZIP code. For
example:

  data zips;
    input zip customerid;
    citystate=zipcity(zip);
    city=scan(citystate,1,',');
  cards;
  27513 762
  33432 338
  07026 267
  ;
  run;

For earlier releases of SAS, you can use the SASHELP.ZIPCODE data set to
obtain the name of the city for a specific ZIP code. The data set is
available for download from the following location:

http://support.sas.com/rnd/datavisualization/mapsonline/html/misc.html

For example, assuming the ZIPS data set given above, the following PROC
SQL statements add the city name to the data set that is created.
Note that you need to change SASHELP.ZIPCODE to point to the SAS
data library where you stored the downloaded ZIPCODE data set.

  proc sql;
    create table zips2 as
    select zips.zip, zips.customerid, b.city  from
    zips as a, sashelp.zipcode as b
    where a.zip=b.zip;
  quit;