Вы ищете что-то вроде этого Красного?
data g;
length act_route_path $ 2 designed_route_path $ 2;`
input act_route_path $ designed_route_path $;
datalines;
xx xy
xx xx
yy yy
yx yy
;
run;
proc sql; create table z as
select act_route_path, designed_route_path,
case when Off_at_Location_1 = 0 and substr2 = 0 then designed_route2
else 'Match' end as result
from(select *
,case when act_route_path = designed_route_path then 1 else 0 end as Off_at_Location_1
,substr(act_route_path,1,1) as act_route1
,substr(act_route_path,1,2) as act_route2
,substr(designed_route_path,1,1) as designed_route1
,substr(designed_route_path,2,1) as designed_route2
,index(substr(act_route_path,1,1),substr(designed_route_path,1,1)) as substr1
,index(substr(act_route_path,2,1),substr(designed_route_path,2,1)) as substr2
from g
)a
;
quit;
Если вы разместите данные, код станет намного чище.