Good day
have a list 20 of programs
Sales.sas
Marketing.sas
HR.sas
all these they have a common macro variable called currentReporingmonth i want to iterate through all of them to find and replace that variable with mon1_date9 and output another sas code with chagnes or file for example
Sales.sas -> Sales1.sas
Marketing.sas -> Marketing1.sas
HR.sas -> HR1.sas
Your help will be highly appreciated
Regards
N
Hi nathilanga,
You could write some Base SAS code to do this, but for 20 files, it would probably be simpler to do it manually.
If you are going to be doing this on a regular basis, and want to write some SAS code to do it, then I'd approach it as follows
Why change the code? Do you assign a value to the macro variable in each file? If that is the case then a likely better approach would be to remove the assignment code an do that in a separate program that then calls the program files with %include statements.
Since you don't actually provide the 1) current macro variable name, 2) how that particular macro variable is used, 3) what you explicitly want the macro variable changed to and 4) source code of at least one of those files, it is very hard to provide any actual concrete code.
And things may get more complicated if any of your program files define or call macros.
Good day
reason for the code change is to standardize it, i have plenty of code that needs to change
so that everyone can use one auto exec for libraries and dates
A proper operating system (read: UNIX) provides a great tool for such text operations, it's called awk.
@Kurt_Bremser wrote:
A proper operating system (read: UNIX) provides a great tool for such text operations, it's called awk.
And Windoze has Powershell for the same job but i would use a text-editor allowing find+replace on multiple files in a folder, e.g. Notepad++.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.