How to search your SAS Enterprise Guide project files

This post was kindly contributed by The SAS Dummy - go there to comment and to read the full post.

If you are like many SAS Enterprise Guide users, you’ve amassed a large collection of project files (EGP files) that contain important content: programs, logs, notes, results, and more.

However, to most tools and processes, the EGP file is opaque. That is, you can’t see what’s inside of it unless you actually open it within SAS Enterprise Guide. And then you might have to poke around for a bit, opening various items until you find the one you’re looking for.

What if you had a way to search your collection of EGP files, without opening them, to find all occurrences of any text that you specify? Would that rock your world?

Introducing…the EG-Project-Search-inator! (That’s my name for it, as I’ve been watching a lot of Phineas and Ferb lately and so I’m inspired by Dr. Doofenshmirtz’s naming conventions. With this, you can search every project file in the Tri-State area!)

The more-mundane-and-less-cool name is EGPSearch, and I built it as an example for my SAS Global Forum paper. It shows how you can use Microsoft .NET to automate SAS Enterprise Guide. But it also turned out to be a very handy tool.

>> DOWNLOAD link for the EGPSearch tool (SAS Enterprise Guide 4.3 only)
The download is a ZIP archive with the EXE and the Microsoft .NET source code that I used to build it.

It’s simple to use. You place the EGPSearch43.exe anywhere on a machine that already has SAS Enterprise Guide 4.3. Then run EGPSearch43.exe to start it. Here’s a screenshot of the user interface:

You specify a project file to search (as a fully qualified path name) or a collection of projects in a folder (using wildcards, such as “C:\Projects\*.egp”). Then specify the text that you want to search for.

The EG-Project-Search-inator will use the SAS Enterprise Guide automation API to open each EGP file and search for the text. The search will include all programs (including task-generated code), log output, notes, and process flow labels. The search is case-insensitive, so searching for “libname”, “LIBNAME”, or “libNAME” will find all of the same content. All of the results (“hits”) will be displayed as a list in the main window. The log area at the bottom will show you which project files were opened and searched successfully.

With a tool like this, you can begin to answer all sorts of questions, such as:

  • Where am I using a LIBNAME statement in my code? (Administrators would love to know!)
  • I say that I love PROC SGPLOT, but how much do I really use it?
  • What projects have ERROR lines in the logs? How about WARNING lines?

If you have burning questions that you want to pose to the Search-inator, download it today and give it a try.

Important notes about the EG-Project-Search-inator!

Before you download this tool, there are a few things you should know.

This tool is provided as an example, and isn’t supported by SAS Technical Support. If you have questions or feedback about the tool (such as “Works great!” or “Curse you, Perry the Platypus!”), please tell me in the comments.

It works only with SAS Enterprise Guide 4.3. I’m working on a 5.1 version, but I’m not ready to release it yet. The 4.3 version might have some luck with project files from 4.1 or 4.2, but don’t count on it. And because it uses the Version 4.3 automation APIs, you must have SAS Enterprise Guide 4.3 installed on your machine.

You might see a bunch of files/folders that are created during a search, but that don’t get cleaned up. As a by-product of searching a project file, some of the project internal files are copied to a temporary folder for searching, and then are removed when the search is complete. However, some users have seen these files land in the current working folder (which not always a TEMP folder), and then remain even after closing the tool.

Even when you close the tool, the EGPSearch43.EXE process might not end immediately. This is most likely to happen when there is an error trying to open one or more EGP files from a folder. This doesn’t hurt anything, but you might find that one of your EGP files is “locked for read” if you try to open it in the full SAS Enterprise Guide interface. Simply use Windows Task Manager to end the EGPSearch43.EXE process, which will free the file.

You should install the most recent SAS Enterprise Guide 4.3 hotfixes, as there are fixes that may help the tool to behave better, and might avoid the issues I just described.

tags: .net, automation, EG-Project-Search-inator, SAS Enterprise Guide

This post was kindly contributed by The SAS Dummy - go there to comment and to read the full post.