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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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