This should give what you're looking for:
data have1;
infile datalines dsd dlm=',' ;
input name :$6. id :$3. date :MMDDYY10. city_name :$12. ;
datalines;
Max,010,01/10/2017,Almeda
Robin,023,.,Sacramanto
Sandra,125,08/10/2013,LA
Bob,200,01/12/2016,Woodland
John,202,05/30/2014,L.A.
;
run;
data have2;
infile datalines dsd dlm=',' ;
input correct_name :$15. incorrect_name1 :$15. incorrect_name2 :$15. incorrect_name3 :$15. incorrect_name4 :$15. incorrect_name5 :$15. ;
datalines;
Sacramento, Sacraminto, Sacrament, Sacramintu, Scraminto, Sacramanto
Los Angeles,Loss Angeles,LA,LAngeles,L.A.,-
Woodland,Woodland,Woodland,-,-,-
Richmond,Rchmond,Richmand,Richmon,-,-
Alameda,Almeda,-,-,-,-
;
run;
proc sql;
create table want as
select a.name
,a.id
,a.date format MMDDYY10.
,case
when b.correct_name is null
then a.city_name
else b.correct_name
end as city_name
from have1 a
left join have2 b
on (a.city_name = b.incorrect_name1
or a.city_name = b.incorrect_name2
or a.city_name = b.incorrect_name3
or a.city_name = b.incorrect_name4
or a.city_name = b.incorrect_name5)
;
quit;
... View more