Here is an example that short circuits to the next page when "BOOK A" is not found in the third read of each page.
[pre]
filename FT15F001 temp recfm=F lrecl=161;
data _null_;
infile FT15F001 eof=eof end=eof;
array line[50] $161; *array dim should equal report page size;
keeperFlag = 0;
do _n_ = 1 by 1 until(cc eq '1');
input @1 line[_n_] $char161. @@;
if _n_ eq 3 and not index(line[_n_],'BOOK A') then do;
do until(cc eq '1');
input / @1 cc $1. @@;
end;
delete;
end;
input / @1 cc $1. @@;
end;
eof:
file print noprint ls=161;
do _n_ = 1 to _n_;
put line[_n_] $char161.;
end;
parmcards4;
1$$DJDE JDE=STD15,SIDE=(NUFRONT,NOFFSET),END;
JNM: GSGB020 P R I V A T E L A B E L
PGM: GSGB020 BOOK A G R O U P B U Y O R D E R
0
CA
ITEM PACK SIZE DESCRIPTION O.I. REBATE CO
ITEM PACK SIZE DESCRIPTION O.I. REBATE CO
ITEM PACK SIZE DESCRIPTION O.I. REBATE CO
ITEM PACK SIZE DESCRIPTION O.I. REBATE CO
ITEM PACK SIZE DESCRIPTION O.I. REBATE CO
ITEM PACK SIZE DESCRIPTION O.I. REBATE CO
0 0001 PRIVATE LABEL MANDARIN ORANGES
1$$DJDE JDE=STD15,SIDE=(NUFRONT,NOFFSET),END;
JNM: GSGB020 P R I V A T E L A B E L
PGM: GSGB020 BOOK B G R O U P B U Y O R D E R
0
CA
ITEM PACK SIZE DESCRIPTION O.I. REBATE CO
0 0002 PRIVATE LABEL MANDARIN ORANGES
1$$DJDE JDE=STD15,SIDE=(NUFRONT,NOFFSET),END;
JNM: GSGB020 P R I V A T E L A B E L
PGM: GSGB020 BOOK A G R O U P B U Y O R D E R
0
CA
ITEM PACK SIZE DESCRIPTION O.I. REBATE CO
0 0003 PRIVATE LABEL MANDARIN ORANGES
1$$DJDE JDE=STD15,SIDE=(NUFRONT,NOFFSET),END;
JNM: GSGB020 P R I V A T E L A B E L
PGM: GSGB020 BOOK A G R O U P B U Y O R D E R
0
ITEM PACK SIZE DESCRIPTION O.I. REBATE CO
ITEM PACK SIZE DESCRIPTION O.I. REBATE CO
ITEM PACK SIZE DESCRIPTION O.I. REBATE CO
CA
ITEM PACK SIZE DESCRIPTION O.I. REBATE CO
0 0004 PRIVATE LABEL MANDARIN ORANGES
0
CA
ITEM PACK SIZE DESCRIPTION O.I. REBATE CO
0 0004 PRIVATE LABEL MANDARIN ORANGES
;;;;
run;
[/pre]