Previous Page | Next Page

Functions and CALL Routines

ZIPCITYDISTANCE Function



Returns the geodetic distance between two ZIP code locations.
Category: Distance
Category: State and Zip Code

Syntax
Arguments
Details
Examples
See Also

Syntax

ZIPCITYDISTANCE(zip-code-1, zip-code-2)


Arguments

zip-code

specifies a numeric or character expression that contains the ZIP code of a location in the United States of America.


Details

The ZIPCITYDISTANCE function returns the geodetic distance in miles between two ZIP code locations. The centroid of each ZIP code is used in the calculation.

The SASHELP.ZIPCODE data set must be present when you use this function. If you remove the data set, then ZIPCITYDISTANCE will return unexpected results.

The SASHELP.ZIPCODE data set contains postal code information that is used with ZIPCITYDISTANCE 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]


Examples

In the following example, the first ZIP code identifies a location in San Francisco, CA, and the second ZIP code identifies a location in Bangor, ME. ZIPCITYDISTANCE returns the distance in miles between these two locations.

data _null_;
   distance=zipcitydistance('94103', '04401');
   put 'Distance from San Francisco, CA, to Bangor, ME: ' distance 4. ' miles';
run;

SAS writes the following output to the log:

Distance from San Francisco, CA, to Bangor, ME: 2782 miles


See Also

Functions:

ZIPCITY Function

Previous Page | Next Page | Top of Page