BookmarkSubscribeRSS Feed
SASPhile
Quartz | Level 8

I would like to make changes in all SAS programs in a folder. 

For example I would like to replace "Apple"  with  "Orange" in all the programs that has "Apple". Is there a way to it in one shot?

5 REPLIES 5
PaigeMiller
Diamond | Level 26

You could write SAS code that reads each line of each program in the folder, and then changes "Apple" to "Orange", and then writes the text out to a new file. I wouldn't be surprised if some program to do this already exists. And of course, there are non-SAS ways to accomplish this as well.

 

If the text in this example is something like a server location, or something else that you know might change in the future, I handle this by setting a macro variable with the location of the server location in my AUTOEXEC file, and then I use this macro variable in every program that refers to this server location. At some point in the future, when the server location changes, I only have to change the value of the macro variable assigned in the AUTOEXEC, and all my programs will refer to the new server location.

--
Paige Miller
Kurt_Bremser
Super User

Aside from contemplating the use of (a) macro variable(s), as @PaigeMiller suggested, this might also be an opportunity (if you work on a UNIX system) to get yourself acquainted with find and awk.

SASPhile
Quartz | Level 8

But the OS is Windows.

PaigeMiller
Diamond | Level 26

Google finds many utilities that will do this. Search for

 

bulk change text in folder

--
Paige Miller
andreas_lds
Jade | Level 19
Can you use powershell? Or, if you have notepad++ you can use it to modify all files in a folder.