Converts ZIP codes to uppercase state names
Category: State and ZIP Code
ZIPNAME ( 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, ZIPNAME assumes that the value is 01040.
If the ZIPNAME 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.
ZIPNAME returns the name of the state or U.S. territory that corresponds to its five-digit ZIP code argument. ZIPNAME returns character values up to 20 characters long, all in uppercase.
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=zipname('27511'); put state1; | NORTH CAROLINA |
state2=zipname('01040'); put state2; | MASSACHUSETTS |
state3=zipname(1040); put state3; | MASSACHUSETTS |
state4=zipname('59017'); put state4; | MONTANA |
state5=zipname(24862); put state5; | WEST VIRGINIA |
Functions:
'ZIPCITY Function' on page 919
'ZIPFIPS Function' on page 920
'ZIPNAMEL Function' on page 923
'ZIPSTATE Function' on page 924