Based on the new info you provided I have changed the program to read each line of each page into an array LINE
and if “BOOK A” is found then the page is kept. This is a bit simpler than my other program.
Yes, each line of each page is read into the LINE array. There is only one page at time in the array, and then if it is a good page it is printed. If you know exactly where the KEEP info is you can short circuit the reading similar to my original program.
The elements of the LINE array are variables. The value of each variable is the entire contents of a line. I don't know if I answered all your questions.
[pre]
data _null_;
infile FT15F001 length=l eof=eof;
array line[20] $161; *array dim should equal report page size;
keeperFlag = 0;
do _n_ = 1 by 1 until(cc eq '1');
input @1 line[_n_] $char161. @@;
putlog _infile_;
if not keeperFlag then if index(line[_n_],'BOOK A') then keeperFlag = 1;
input / @1 cc $1. @@;
end;
eof:
file print noprint ls=161;
if keeperFlag then do _n_ = 1 to dim(line);
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
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 C G R O U P B U Y O R D E R
0
CA
ITEM PACK SIZE DESCRIPTION O.I. REBATE CO
0 0004 PRIVATE LABEL MANDARIN ORANGES
;;;;
run;
[/pre]