BookmarkSubscribeRSS Feed
jplarios
Quartz | Level 8
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;
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Your SAS program needs an INPUT; statement to load the input buffer before you can reference _INFILE_.

Scott Barry
SBBWorks, Inc.
jplarios
Quartz | Level 8
Scott,
Thank you!
Juan
deleted_user
Not applicable
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
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1485 views
  • 0 likes
  • 3 in conversation