Date: Sat, 8 Dec 2007 23:08:04 -0800
Reply-To: Patrick <patrick.matter@GMX.CH>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Patrick <patrick.matter@GMX.CH>
Organization: http://groups.google.com
Subject: Re: A bit complicated for me to express
Content-Type: text/plain; charset=ISO-8859-1
Sorry, forgot a case! That's the correct code:
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. ;
CityStateZip=compbl(CityStateZip);
CityStateZip=compress(CityStateZip,',');
ZipCode=scan(CityStateZip ,-1);
State=scan(CityStateZip ,-2);
rc=indexw(CityStateZip, state,' ,');
if rc=0 then
output work.CheckData;
else
do;
City=substr(CityStateZip,1,rc-2);
StateName=StnameL(State);
Location = ZIPCITY(Zipcode);
rc=indexw(Location, State,' ,');
if rc=0 then
output work.CheckData;
else
do;
ZipCity=substr(Location,1,rc-3);
rc=compare(compress(ZipCity), compress(City),'NLI');
if rc ^= 0 then
do;
output work.CheckData;
end;
else
output work.Address;
end;
end;
datalines;
xxx xxx
9999 xx xx Rd
New York, NY 10068
716-555-1348
Sonya Larson
10054 Plum Tree Rd
Buffalo NY 10068
716-555-1348
Peter Simpson
605 Glendover Dr
sabel KS 67065
316-555-6566
Kip Holfser
902 West Blvd
Lansing, MI 48910
517-555-0227
Chan Rong
3052 East Bank Way
Lithonia GA 30058
912-555-0025
Mary Peters
10036 Lake View Dr
Greenbay, WI 54311
608-555-9031
Randy Nguyen
100 49th Street
Harrisburg, PA 19057
717-555-7773
;
|