If I understand what you're doing, which is finding rows in t1 where there is at least one row in t2 such that that t2.id has t1.id as a substring, your problem is probably that t1.id needs to be compressed/trimmed. Otherwise, t1.id will have spaces after its actually useful value padding out to the full string length - in this example, that is 8 long (the default for strings read in the way I read them in for t1).
data t1;
input id $;
datalines;
123
456
789
;;;;
run;
data t2;
input @1 id $8.;
datalines;
123 456
234 567
;;;
run;
proc sql;
select t1.*
from t1,t2
where t2.id contains compress(t1.id);
quit;