The CODE of the data step is compiled BEFORE the step starts running. So you cannot reference the value of a macro variable created while the step is running to change the code since you are already past that point in time.
If you want to use DATA as CODE then the easiest thing is to write it to a code that that you can %INCLUDE.
I could not make any sense out of your example so here is a slightly different one that uses TWO datasets, one with the conditions and another which is the data that will be evaulated.
data conditions;
infile datalines dsd dlm=' ';
input result $ condition :$40.;
datalines;
AAA "name in ('Mary')"
BBB "name in ('Jack', 'Bob')"
;
data person;
input name $;
datalines;
Mary
Jack
Bob
Fred
;
So convert the conditions into code. Perhaps a series of IF/THEN/ELSE statements?
filename code temp;
data _null_;
file code;
set conditions;
if _n_>1 then put 'else ' @;
put 'if (' condition ') then ' result= $quote. ';' ;
run;
Then use that code in a data step.
data want;
set person;
%include code / source2;
run;
Result
Obs name result
1 Mary AAA
2 Jack BBB
3 Bob BBB
4 Fred
... View more