Previous Page | Next Page

Functions and CALL Routines

ZIPCITY Function



Returns a city name and the two-character postal code that corresponds to a ZIP code.
Category: State and ZIPCode

Syntax
Arguments
Details
The Basics
How the ZIP Code Is Translated to the State Postal Code
Determining When the State Postal Code Table Was Last Updated
Comparisons
Examples
See Also

Syntax

ZIPCITY(zip-code)


Arguments

zip-code

specifies a numeric or character expression that contains a five-digit ZIP code.

Tip: If the value of zip-code begins with leading zeros, you can enter the value without the leading zeros. For example, if you enter 1040, ZIPCITY assumes that the value is 01040.

Details


The Basics

If the ZIPCITY function returns a value to a variable that has not yet been assigned a length, by default the variable is assigned a length of 20.

ZIPCITY returns a city name and the two-character postal code that corresponds to its five-digit zip code argument. ZIPCITY returns the character values in mixed-case. If the zip code is unknown, ZIPCITY returns a blank value.

Note:   The SASHELP.ZIPCODE data set must be present when you use this function. If you remove the data set, ZIPCITY will return unexpected results.   [cautionend]


How the ZIP Code Is Translated to the State Postal Code

To determine which state corresponds to a particular ZIP code, this function uses a zone table that consists of the start and end ZIP code values for each state. It then finds the corresponding state for that range of ZIP codes. The zone table consists of start and end ZIP code values for each state to allow for exceptions, and does not validate ZIP code values.

With very few exceptions, a zone does not span multiple states. The exceptions are included in the zone table. It is possible for new zones or new exceptions to be added by the U.S. Postal Service at any time. However, SAS software is updated only with each new release of the product.


Determining When the State Postal Code Table Was Last Updated

The SASHELP.ZIPCODE data set contains postal code information that is used with the ZIPCITY and other ZIP code functions. This data set is updated with each new release of SAS software. To determine when this table was last updated, execute PROC CONTENTS:

proc contents data=SASHELP.ZIPCODE;
run;

Then view the label information for the SASHELP.ZIPCODE data set:

Label                zipcodedownload.com                                      
                     April2004, UNIQUE-updated                                
                     (sorted) February                                        
                     2006, Release 9.2  

The label shows that zipcodedownload.com is the site from which the ZIP codes were downloaded, and that April 2004 is the date that the ZIP codes were last refreshed. February 2006 is the last date that modifications were made to SASHELP.ZIPCODE.

Note:   You can download the latest version of the SASHELP.ZIPCODE file from the SAS external Web site at any time. The file is located at http://support.sas.com/rnd/datavisualization/mapsonline/html/misc.html. Select Zipcode Dataset from the Name column to begin the download process. You must execute the CIMPORT procedure after you download and unzip the data set.  [cautionend]


Comparisons

The ZIPCITY, ZIPNAME, ZIPNAMEL, and ZIPSTATE functions accept the same argument but return different values:


Examples

The following SAS statements produce these results.

SAS Statements Results
city1=zipcity(27511);
put city1;
 
Cary, NC
length zip $10.;
zip='90049-1392';
zip=substr(zip,1,5);
city2=zipcity(zip);
put city2;
 



Los Angeles, CA
city3=zipcity(4338);
put city3;
 
Augusta, ME
city4=zipcity(01040);
put city4;
 
Holyoke, MA


See Also

Functions:

ZIPNAME Function

ZIPNAMEL Function

ZIPSTATE Function

ZIPFIPS Function

Previous Page | Next Page | Top of Page