DATA Step, Macro, Functions and more

Use SAS to search for key names in other SAS Programs

Reply
Super Contributor
Posts: 252

Use SAS to search for key names in other SAS Programs

Hey,

Is it possible for SAS to search for other SAS Programs in a given directory, and then open up the program and search for a specific name?


For example, in every SAS Program I write, I put my name in the Code Header. I would like to find all the SAS programs that include my name within a particular directory.

Many thanks in advance Smiley Happy,

Kriss Harris

Respected Advisor
Posts: 3,777

Re: Use SAS to search for key names in other SAS Programs

You can probability find really good examples by searching these forums

You will need to learn about

  1. PIPE access method to build a list of files to open and search
  2. FILEVAR= infile statement option
  3. END= infile statement option
  4. DO WHILE(NOT end of file)
  5. FILENAME= infile statement option maybe.
  6. special variable _INFLE_
  7. INPUT;
  8. FIND and or FINDW or PRXfunctions(for complex finds)
  9. RETURN statement
  10. And a few "connecting" statements

It's really quite easy I do it all the time.

Super Contributor
Posts: 252

Re: Use SAS to search for key names in other SAS Programs

Thank you for your guidance! It's well appreciated Smiley Happy I have seen other papers mentioning the PIPE statement too so I will research the above.

I was just looking into the systask command too, but the above way seems like the way to go!

Thank you.

Regards Kriss

Respected Advisor
Posts: 3,777

Re: Use SAS to search for key names in other SAS Programs

You could use SYSTASK to run a DIR command and use output redirection to send the output to a file and then read that file using SAS INFILE.

With PIPE the file(DIR COMMAND) is executed when the file is opened with INFILE and the output is sent to SAS as if it were any other file.  The same but different.Smiley Happy

Super Contributor
Posts: 252

Re: Use SAS to search for key names in other SAS Programs

Okay I see now.

Thanks for the clarification! Smiley Happy

Ask a Question
Discussion stats
  • 4 replies
  • 250 views
  • 7 likes
  • 2 in conversation