Help using Base SAS procedures

searching string through programs

Reply
Regular Contributor
Posts: 163

searching string through programs

I want to search through a bunch of sas programs and find one word strings. The ouput dataset called found contains the job that has the matching string.
This is one way I approached it but get stock when trying to output or using the filevar:

I created a proglist text file that contains all my programs ( more than a 100) which I loaded them into a sas data set named progs. I take this progs set and

data progs;
infile proglist;
input @1 program $88.;
run;

filename name '/dir/';


data found;
set progs;
prog = '/dir/'||program;
infile name filevar=prog end=done;
do while (not done);
if index(_INFILE_, "FINDTHIS") > 0 then do; found = 1;output; end;
end;
run;
Super Contributor
Super Contributor
Posts: 3,174

Re: searching string through programs

Your SAS program needs an INPUT; statement to load the input buffer before you can reference _INFILE_.

Scott Barry
SBBWorks, Inc.
Regular Contributor
Posts: 163

Re: searching string through programs

Scott,
Thank you!
Juan
N/A
Posts: 0

Re: searching string through programs

Juan -
If you only wanted to get one observation per file then you could add a little more logic to your do loop.

found=0;
do while (not done and not found);
if index(_INFILE_, "FINDTHIS") > 0 then do; found = 1;output; end;
end;

- Tom
Ask a Question
Discussion stats
  • 3 replies
  • 100 views
  • 0 likes
  • 3 in conversation