BookmarkSubscribeRSS Feed
djrisks
Barite | Level 11

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

4 REPLIES 4
data_null__
Jade | Level 19

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.

djrisks
Barite | Level 11

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

data_null__
Jade | Level 19

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

djrisks
Barite | Level 11

Okay I see now.

Thanks for the clarification! Smiley Happy

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

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
  • 4 replies
  • 797 views
  • 7 likes
  • 2 in conversation