Convert your set of variables to a string, and then use the indexc function on that string to search for characters represent each of your criteria:
data have;
input id $ var1-var4;
datalines;
A 1 2 4 7
B 0 2 3 8
C 4 2 6 3
D 7 4 5 2
E 1 9 6 3
run;
data _null_;
set have end=last_case;
array n {3} n_47 n_2 n_3;
array c {3} $2 _temporary_ ('47', '2', '3');
cat_vars=cats(of var1-var4);
do v=1 to dim(n);
n{v}+(indexc(cat_vars,trim(c{v}))>0);
end;
if last_case then put (N_:) (=);
run;
Of course, INDEXC works only when your search criteria are collections of single characters.
Edited addition: I started thinking about search for collections of multi-character values, using the same general strategy. Here's an example using the FINDW function. Instead of looking for (a) 4 or 7, (b) 2, or c(3) 3, it looks for 2-digit numbers 14 or 17, 12, or 13:
data have;
input id $ var1-var4;
datalines;
A 11 12 14 17
B 10 12 13 18
C 14 12 16 13
D 17 14 15 12
E 11 19 16 13
run;
data _null_;
set have end=last_case;
array n {3} n_1417 n_12 n_13;
array c {3} $5 _temporary_ ('14 17', '12', '13');
length cat_vars $20;
cat_vars=catx(' ',of var1-var4);
do I=1 to dim(n);
found=0;
do J=1 to countw(c{I}) until (found^=0);
found=findw(cat_vars,scan(c{I},J));
end;
n{I}+(found>0);
end;
if last_case then put (N_:) (=);
run;
... View more