If I understand right what you're trying to do then below should work.
data person;
infile datalines truncover dsd dlm=' ';
input name $ condition $100.;
datalines;
John name not in ('Mary')
Mary name not in ('Jack', 'Bob')
;
filename codegen temp;
data _null_;
file codegen;
set person end=last;
if _n_>1 then put 'else ' @;
put 'if ' condition 'then output pass;';
if last then put 'else output error;';
run;
data error pass;
set person;
%include codegen / source2;
run;
Generated code from SAS log:
45 data error pass;
46 set person;
47 %include codegen / source2;
NOTE: %INCLUDE (level 1) file CODEGEN is file
C:\Users\*****\AppData\Roaming\SAS\EnterpriseGuide\EGTEMP\SEG-11160-3cba2e81\contents\SAS Temporary
Files\_TD1604_SSAPAM3_\#LN00150.
48 +if name not in ('Mary') then output pass;
49 +else if name not in ('Jack', 'Bob') then output pass;
50 +else output error;
NOTE: %INCLUDE (level 1) ending.
51 run;
...but then looking at your sample data may be you want below code generated?
filename codegen temp;
data _null_;
file codegen;
set person end=last;
_cond=condition;
_cond=tranwrd(_cond,'name',cats("'",name,"'"));
if _n_>1 then put 'else ' @;
put 'if ' _cond 'then output pass;';
if last then put 'else output error;';
run;
data error pass;
set person;
%include codegen / source2;
run;
47 data error pass;
48 set person;
49 %include codegen / source2;
NOTE: %INCLUDE (level 1) file CODEGEN is file
C:\Users\*****\AppData\Roaming\SAS\EnterpriseGuide\EGTEMP\SEG-11160-3cba2e81\contents\SAS Temporary
Files\_TD1604_SSAPAM3_\#LN00198.
50 +if 'John' not in ('Mary') then output pass;
51 +else if 'Mary' not in ('Jack', 'Bob') then output pass;
52 +else output error;
NOTE: %INCLUDE (level 1) ending.
53 run;
... View more