LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Sun, 25 Nov 2007 14:51:56 -0500
Reply-To:   Phil Rack <philrack@MINEQUEST.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Phil Rack <philrack@MINEQUEST.COM>
Subject:   Re: ZIPSTATE function, turn off invalid argument NOTE?
Comments:   To: Paul Dorfman <sashole@BELLSOUTH.NET>
In-Reply-To:   A<112520071807.16522.4749B9D4000E022A0000408A22243651029B0A02D2089B9A019C04040A0DBF0A0401089C0E9C@att.net>
Content-Type:   text/plain; charset="us-ascii"

Hi Paul,

You are absolutely correct on the first three characters of a zip code NOT being state specific. An interesting aberration is with the zip code 06390. This zip is actually in NY but is served by a post office in CT. I created a set of macros for WPS to emulate some of the ZipState functions that SAS has and WPS does not. What I decided to do is make the zip code 06390 return NY and not CT because I want to know the state of that zip code and not what post office is serving that zip. Hence, my macro differs from SAS's function.

Check out http://en.wikipedia.org/wiki/ZIP_code for a better explanation than I offer above. Btw, my ZipState macro can be found at: http://minequest.com/downloads.html and the documentation can be read at: http://minequest.com/macrotoolkit/help/

Phil Rack MineQuest, LLC SAS Consulting and Contract Programming Services

Web: www.MineQuest.com Tel: (614) 457-3714 Web Conference: SightSpeed -----Original Message----- From: Paul Dorfman [mailto:sashole@BELLSOUTH.NET] Sent: Sunday, November 25, 2007 1:07 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: ZIPSTATE function, turn off invalid argument NOTE?

Richard,

I would abstain from using the function at all if your purpose is indeed to return the state from the first 3 zip digits, the reason being two-fold:

1. The correspondence between int(zip/100) and state is not unique. For example, a simple

select * from (select distinct put (int(zip/100), z3.) as zip3, statecode as st from sashelp.zipcode) group zip3 having count(*) > 1

reveals:

zip3 st ------- 063 CT 063 NY 834 ID 834 WY 969 GU 969 MP 969 PW

Hence I have to take issue with your description of what the function does. It accepts the full zip as its argument for a reason - a full zip corresponds to a unique state.

2. The function does not validate zip codes. Hence, if you need accuracy (and I presume you do) you had better use sashelp.zipcode to emulate the function via a format or hash, which would tangentially also eliminate the log notes issue you started with. Ideally, sashelp.zipcode being used should be freshly updated from the data set whose location is referenced in the SAS documentation:

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

Kind regards ------------ Paul Dorfman Jax, FL ------------

-------------- Original message ---------------------- From: "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET> > > The ZIPSTATE function evaluates the first three digits of a zip code (the > zone) and returns the state that corresponds to the zone. > > data x; > do zip = 0 to 1e5 by 1e2; > state = zipstate(zip); > if state eq '' then put zip= state=; > end; > run; > > When a zipcode is in invalid there is the following in the log: > NOTE: Invalid argument to function ZIPSTATE at line # column #. > > Is there a way to turn this note off, and leave other notes on ? > > Looking for something like the ?? of INPUT(), such as > input ('ABC', ?? 3.) > which prevents _error_ from being assigned. > > > > -- > Richard A. DeVenezia


Back to: Top of message | Previous page | Main SAS-L page