Date: Sat, 8 Dec 2007 20:51:50 -0800
Reply-To: SAS Student <o.ibrahim0@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: SAS Student <o.ibrahim0@GMAIL.COM>
Subject: A bit complicated for me to express
Content-Type: text/plain; charset=ISO-8859-1
I am sorry for the repost but there was something wrong with my
original one. Anyway here it goes:
I have a small problem that I need to solve and would appreciate any
help you offer.
I created a table with some patients names, phone numbers, and
addresses (SAS code and datalines provided below) . I created the
Location variable using the ZIPCITY function. If you submit the
program you will see that in the last observation the City "Harrisbu"
does not match the city under Location "Levittown" while for the first
observation the Location is left blank because the
zipcode is invalid. I need a simple code that does the following:
1.If they zipcode does not match the city/state (6th observation),
then I need to create a code that either edits the zipcode or city/
state so that they match. One way is is to compare the "City" variable
with the first part
(city part) of the "Location" varaible and asking SAS to replace the
former with the latter if they don't match (e.g replace Harrisbu with
Levittown). Needless to say, I don't now
how to do that...
2. If the Zipcode is invalid (1st observation) i need to replace its
value with "???"
This is just part of the dataset so I need something that is global.
Also, please keep it as simple as possible so that I can understand
what you did. Thanks a lot !
Data Address ;
Length Phone1 $ 12. phone 6. City $ 25. zipcode $ 5.;
Input #1 PatientName&$ 25. #2 StreetAddress&$ 30.
#3 City1 $ State $ 2. zipcode $ 6. #4 Phone1 $ ;
Phone2 = compress(Phone1,'(-) ');
City= compress (City1, '(,) ');
Phone = input(phone2, 9.);
Drop Phone1 phone2 City1;
location = ZIPCITY(Zipcode);
10054 Plum Tree Rd
Buffalo NY 10068
605 Glendover Dr
I 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