The following may be overkill, but it does let you read the data twice, get rid of the undesired records, yet result it no errors in the log:
data recs (keep=_recnum);
infile '/folders/myfolders/datahave.txt' end=eof;
do until (eof);
input;
rec_count+1;
if scan(_infile_,1) eq 'paris' then do;
_recnum=rec_count;
output;
_recnum=rec_count-1;
output;
end;
else if scan(_infile_,1) eq 'madrid' then do;
_recnum=rec_count;
output;
_recnum=rec_count-1;
output;
_recnum=rec_count+1;
output;
end;
end;
run;
data want (drop=_:);
array _drops (999999) _temporary_;
do until (eof1);
set recs end=eof1;
_rec_num+1;
_drops(_rec_num)=_recnum;
end;
_rec_num=0;
infile '/folders/myfolders/datahave.txt' end=eof2;
do until (eof2);
_rec_num+1;
input @;
if _rec_num not in _drops then do;
input var1$ var2 var3;
output;
end;
else input;
end;
run;
Art, CEO, AnalystFinder.com
... View more