BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GreggB
Pyrite | Level 9

I want to search my network drive for SAS programs that have a key word I'm looking for.  When I was running XP, i could do a search such as *.*sas and it would prompt me for any word I wanted to include in the contents of the file.  If I typed "PROC IMPORT" (without the double quotes) I would get all SAS programs that had PROC IMPORT in the program.  I have no such luck in Windows 7.

1 ACCEPTED SOLUTION

Accepted Solutions
FriedEgg
SAS Employee

In command prompt:

 

Search the H drive for all files with extension of sas for string obs=max

 

for /r H: %i in (*.sas) do @findstr /i /m "obs=max" "%i"

 

In sas your could execute this in a filename pipe and then collect all the relevant filenames inside a data step.

 

filename search pipe 'for /r H: %i in (*.sas) do @findstr /i /m "obs=max" "%i"';
 
data search_results;
  infile search length=_len;
  input @1 filepath $varying512. _len;
run;

View solution in original post

12 REPLIES 12
art297
Opal | Level 21

Actually, the same problem existed in XP, but you apparently had SAS identified as a valid search extension.

I'm still on XP and had to look up how to correct the matter.  For anyone interested, you can find the solutions (I chose the one at the bottom of the page that didn't require playing with the registry:

http://www.dslreports.com/faq/9500

And, while I haven't had much experience with Windows 7, I think that you may be able to find the solution at:

http://helpdeskgeek.com/windows-7/windows-7-file-search-indexing-options/

Let the forum know if that corrected the situation.

OS2Rules
Obsidian | Level 7

Hi:

By default, the Windows 7 search will not examine the contents of the file and the indexing that Art is referring to only works on the file name.

Here is a better link on how to search file contents with Windows 7:

http://lifehacker.com/5666506/set-windows-7-search-to-always-index-file-contents

GreggB
Pyrite | Level 9

I'm trying the step in the first post but in the 2nd post I can't find "enabling universal content search" in the Search tab.

art297
Opal | Level 21

I would think that my translate to the "always search file names and contents (this might take several minutes)" option on the search options menu

FriedEgg
SAS Employee

In command prompt:

 

Search the H drive for all files with extension of sas for string obs=max

 

for /r H: %i in (*.sas) do @findstr /i /m "obs=max" "%i"

 

In sas your could execute this in a filename pipe and then collect all the relevant filenames inside a data step.

 

filename search pipe 'for /r H: %i in (*.sas) do @findstr /i /m "obs=max" "%i"';
 
data search_results;
  infile search length=_len;
  input @1 filepath $varying512. _len;
run;
GreggB
Pyrite | Level 9

This is excellent!  When I searched the H drive it worked great.  I'm not sure what to do with the part that starts with "filename search pipe......"

FriedEgg
SAS Employee

It is only necessary if you wanted to perform the search through sas and have the results returned in a data set.  Also there is a typo in my code len=_len should read length=_len.

GreggB
Pyrite | Level 9

Holy s**t!!  This is incredible.  Once I corrected your typo, off she flew.  I can play Traffic Rush the rest of the day.

art297
Opal | Level 21

Gregg,

I have a complaint to raise!  How could FriedEgg provide such an incredible finding, but you credit yourself for having provided the answer?  Am I missing something here?

GreggB
Pyrite | Level 9

Apparently I don't know all the intricasies of this site but I take no credit for the solution.  Fried Egg is the top dog on this topic.

art297
Opal | Level 21

Gregg,

Understood.  It is a fairly new model for the site and there aren't a lot of initricasies.  Simply bring up his post and click on the "correct" button or, if that is no longer available, the "helpful" button.  Except for the handful of
SAS employees that are here, the majority of respondents are just other users like you and me.  The formal recognition they get is through obtaining approval ratings from their peers.

PLee
SAS Employee

I ran into a similar problem and my solution was to build a SAS macro that would search within sas programs to find the string.

Here is a link to the macro that my colleague and I wrote.

http://www.torsas.ca/attachments/File/09162011/macro-that-hunts.txt

You should be able to put in the drive/directory you want to search, the file type (in this case .sas) and the string you want to look for.  Keep the proc printto statements as we found the macro ran a lot faster.

Hope that helps and is what you are looking for.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 12 replies
  • 8436 views
  • 1 like
  • 5 in conversation