/* A macro variable list can be evaluated using the scan function in SAS to look for items in your dataset. The amount of code to accomplish this is short, but this technique can be used across a host of applications. This technique was supplied by Eugene Tsykalov at a SAS conference in 2003. *Note, the following code only works on Character variables. */ data mydata; input Y VAR1 VAR2 $ VAR3 ; cards; 1 10 yy 4 0 . hg 3 1 30 fd6 2 1 20 gh 1 0 . 65 3 0 20 ws2 . 1 10 dc 2 1 . tg9 2 0 30 yhn 2 1 20 uij 2 1 20 yg 1 0 . jk 3 0 20 lk2 . 1 10 lk 2 1 . uh2 6 0 30 uu 2 ; %let mylist= uu yg; data mydata2; set mydata; i=1; do while (scan("&mylist",i,'')^=''); if(upcase(VAR2)=scan(upcase("&mylist"),i,'')) then FLAG=1; i+1; end; drop i; run; title Flagging records meeting MYLIST criteria; proc print;run;