Your question is one of performing a lookup. In SQL creating a table with a resolved lookup generally involves the use of a LEFT JOIN.
data one;
length var1 var2 $8;
input var1 var2;
datalines;
abcdef qwerty
bcdefg tyuiop
cdefgh zxcvb
run;
data two;
length var3 var4 $8;
input var3 var4;
datalines;
abcde Richard
xyzab Linus
run;
proc sql;
create table one_tagged as
select
one.*
, two.var4 as tag
from
one
left join
two
on
substr(one.var1,1,5) = two.var3
;
quit;
Note that these types of joins are often utilized as a VIEW stored in a permanent library (create view instead of create table). That way the join is always upto date.
Furthermore, this type of lookup (left join) can also be accomplished using custom formats. A common use of formats is to map a range of values to some other value (a lookup)
Richard A. DeVenezia
http://www.devenezia.com