Date: Sat, 8 Dec 2007 23:01:36 -0800
Reply-To: Patrick <patrick.matter@GMX.CH>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Patrick <patrick.matter@GMX.CH>
Subject: Re: A bit complicated for me to express
Content-Type: text/plain; charset=ISO-8859-1
Hi SAS Student
I don't see a way to decide with 100% accuracy whether City or ZipCode
are correct if they don't match. Therefore I think there is no such
thing like scripted correction of your data.
Of course: In case of a missmatch you could loop through all possible
zip-codes, generate the according City name and compare it with the
City name you have - and then take the zip-code which fits. But: What
if the Zip-code is correct and the City name wrong?
I think it's better to generate a data set and have a look at
incorrect data - and correct them manually (if it's not too much).
Find below an example which would do such a thing.
Hope that helps a bit
Data work.Address(drop=rc CityStateZip ZipCity)
work.CheckData(drop=rc CityStateZip) ;
infile datalines truncover;
length City $ 25 State $ 2 ZipCode $ 5;
Input #1 PatientName $25.
#2 StreetAddress $30.
#3 CityStateZip $33.
#4 Phone:comma12. ;
rc=indexw(CityStateZip, state,' ,');
if rc=0 then
Location = ZIPCITY(Zipcode);
rc=indexw(Location, State,' ,');
if rc>0 then
if rc ^= 0 then
9999 xx xx Rd
New York, NY 10068
10054 Plum Tree Rd
Buffalo NY 10068
605 Glendover Dr
sabel KS 67065
902 West Blvd
Lansing, MI 48910
3052 East Bank Way
Lithonia GA 30058
10036 Lake View Dr
Greenbay, WI 54311
100 49th Street
Harrisburg, PA 19057