Hi Folks,
How can i scan list of keywords on multiple SAS programs files. By SAS or Shell Script or any other way to achieve it?
Thanks
I always do this
cd directory_with_program_files grep keyword *.sas
(SAS server runs on AIX)
Hi Kurt,
I am trying below mentioned code in SAS but its not working. Also if i want to search more than one keyword - e.g. along with libname, infile, import, how to do it ?
Thanks.
filename find 'grep "libname" Path*.sas';
data test;
infile find truncover;
input find_words $100.;
run;
You missed a keyword:
filename find pipe 'grep "libname" Path*.sas 2>&1';
data test;
infile find truncover;
input find_words $100.;
run;
I also added a redirection of stderr to stdout, so that all possible responses will be caught in the data step.
HI Kurt,
I am getting this error while executing the code:
Then you have, unfortunately, XCMD disabled. Get in touch with your SAS admins to have it enabled.
Hi @Codexgo,
A "cousin" of grep in the Windows world is findstr (to be used on the command line, cmd.exe):
findstr "keyword1 keyword2 ..." *.sas
would find all lines in .sas files in the current folder containing one or more keywords from the list. Various options could be specified to modify the search, e.g., /s to extend it to all subfolders.
Similar functionality ("Find in files") is offered by some text editors (and other utility software) and, of course, you could write a SAS program for this purpose. I mostly use findstr.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.