Converts ZIP codes to two-character state postal codes
Category: State and ZIP Code
ZIPSTATE ( zip-code )
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 zeroes. For example, if you enter 1040, ZIPSTATE assumes that the value is 01040.
If the ZIPSTATE 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.
ZIPSTATE returns the two-character state postal code (or world-wide GSA geographic code for U.S. territories ) that corresponds to its five-digit ZIP code argument. ZIPSTATE returns character values in uppercase.
Note: The first three digits of the ZIP code identifies a zone. ZIPSTATE evaluates the zone, and provides a state for that zone. It does not validate the ZIP code.
The ZIPCITY, ZIPNAME, ZIPNAMEL and ZIPSTATE functions take the same argument but return different values:
ZIPCITY returns the uppercase name of the city and the two-character postal code that corresponds to its five-digit ZIP code argument.
ZIPNAME returns the uppercase name of the state or U.S. territory that corresponds to its five-digit ZIP code argument.
ZIPNAMEL returns the mixed case name of the state or U.S. territory that corresponds to its five-digit ZIP code argument.
ZIPSTATE returns the uppercase two-character state postal code (or world-wide GSA geographic code for U.S. territories) that corresponds to its five-digit ZIP code argument.
The following SAS statements produce these results.
SAS Statements | Results |
---|---|
state1=zipstate('27511'); put state1; | NC |
state2=zipstate('01040'); put state2; | MA |
state3=zipstate(1040); put state3; | MA |
state4=zipstate(59017); put state4; | MT |
state5=zipstate(24862); put state5; | WV |
Functions:
'ZIPFIPS Function' on page 920
'ZIPNAME Function' on page 921
'ZIPNAMEL Function' on page 923
'ZIPCITY Function' on page 919