Date: Mon, 28 Feb 2005 13:56:30 -0500
Reply-To: "Michael S. Zdeb" <msz03@HEALTH.STATE.NY.US>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Michael S. Zdeb" <msz03@HEALTH.STATE.NY.US>
Subject: Re: FIPS Codes
Content-type: text/plain; charset=US-ASCII
Hi. You can get the state numbers with a function, STFIPS. However, you
have to convert the full state names to their two character postal
abbreviations. I don't think that there's a county function (could not
find one), but...
If you have licensed SAS/Graph, there is a SAS-supplied data set CNTYNAME.
Among the variables in the data set are: STATE and COUNTY, both NUMERIC
FIPS codes; COUNTYNM, uppercase county name; STATENAME, mixed case state
name. I'd convert all the text to uppercase in data set CNTYNAME and your
data set, use COMPRESS to get rid of any blank spaces in names with more
than one part then just use MERGE or SQL to match the two files. I
haven't looked at every entry in CNTYNAME to see if there are any
abbreviations (or periods) in the names. You'd have to match by state and
county since county names repeat accross states.
set maps.cntyname (keep=state county countynm statename);
countynm = compress(countynm);
statename = upcase(compress(statename));
<do the same with your data>
<merge or SQL>
Or, if you do not have SAS/Graph, take a look at...
It's the SAS code from my mapping book (yes, shameless self promotion).
There's a data step in the code with county names, state abbreviations (not
names, sorry), state and county FIPS codes. You can convert the
2-character state abbreviations to uppercase state names using the STNAME
U@Albany School of Public Health
1 University Drive
Rensselaer, NY 12144-3456