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

I need to change a variable name across all programs in a project. I'm going to go ahead and do a CTRL+H find and replace manually, and furthermore, replace it with a macro parameter that I'll add to the macros in which this variable resides (I know that it could have been done in the first place, but it wasn't).

I don't expect there's a better way but I just wanted to ask. I became familiar with Chris Hemedinger's article about searching SAS projects recently, but I do not believe that would allow for replacing text within programs.

Any suggestions for my future edification?

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

Unfortunately, there is not a find-and-replace tool that operates across all objects in a project, let alone across several projects.

The EGP Search tool can help you identify the items that you might need to change, but you'll have to open each project and change each manually.

Chris

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!

View solution in original post

5 REPLIES 5
Doc_Duke
Rhodochrosite | Level 12

No quick, easy answer.  Technically, you could do it in SAS, but it would be a lot of work.  Depends on how many files....

  1. there are macros on the forums to loop through a series of files (usually Excel, but just change the extension)
  2. read the text in a data step, each line as one long string
  3. use the perl regular expression tools to do the search and replace
  4. write the text back out

Unless you already know how to use perl, 3 might be a challenge.

If you are familiar with Unix scripting, you could download the "GNU on Windows" tools and write the script as a batch file.

Doc Muhlbaier

Duke

PaigeMiller
Diamond | Level 26

I have done this (not for EG, but just regular SAS, as I don't use EG)

Basically, Doc has the answer, but for his step 3, I just used ordinary SAS code, not Perl regular expressions. The FIND command in SAS is useful for finding lines that have the desired target string, and the SUBSTR command allows you to pull apart the text and make replacements.

--
Paige Miller
cau83
Pyrite | Level 9

Doc & Paige, thanks for those suggestions. The drawback is that (and I didn't make this explicit before) these programs may not be actual physical files-- in an EG project, you can have a program that just lives in the project rather than having a shortcut to a program that lives outside of the project.

ChrisHemedinger
Community Manager

Unfortunately, there is not a find-and-replace tool that operates across all objects in a project, let alone across several projects.

The EGP Search tool can help you identify the items that you might need to change, but you'll have to open each project and change each manually.

Chris

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
loredana
SAS Employee
There is a SAS paper on a macro created with the intention of finding and replacing characters across sas programs. I'm aware you're trying to do this in EG, but maybe reading through it will give you some ideas, or even contacting the author might help. Here you go: http://www.phusewiki.org/docs/2006/P018.pdf

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 5 replies
  • 49410 views
  • 4 likes
  • 5 in conversation