indexw
의 무엇이 잘못 되었나요? proc sql
및 indexw
을 사용하면 매우 간단한 해결책을 얻을 수 있습니다.
샘플 데이터 :
data have_messy;
length messy $100;
messy = 'this is a city name: brisbane' ; output;
messy = 'this is a city name: sydney' ; output;
messy = 'this is a city name: melbourne'; output;
run;
data have_city;
length city $20;
city = 'sydney' ; output;
city = 'brisbane'; output;
run;
예 질의 :
proc sql noprint;
create table want as
select a.*,
b.city
from have_messy a
left join have_city b on indexw(a.messy, b.city)
;
quit;
결과 :
messy city
=============================== =========
this is a city name: sydney sydney
this is a city name: brisbane brisbane
this is a city name: melbourne
조심 - 여러 경우 위의 쿼리는 테이블 A의 행 당 여러 개의 결과를 반환 할 수 있습니다 도시 이름이 있습니다. 요구 사항에 따라 중복 행을 처리하기위한 후속 조치를 실행하는 것이 좋습니다.
아무 문제가 없습니다. 그냥 그 기능을 조인 할 수 있음을 깨닫지 못했습니다 ... 오늘 많이 배웠습니다. 감사! – VR6