Help using Base SAS procedures

SAS Script to edit sas programs in a library

Reply
Contributor
Posts: 74

SAS Script to edit sas programs in a library

Hi,

I have a requirement to change the libnames in a library that houses more than 500 sas programs.Is there any way that I can write a SAS program that goes to each of these programs and changes the

library name?

Please let us know your thoughts or any sample code.

Thanks in advance.

Renjith

Super User
Posts: 11,343

SAS Script to edit sas programs in a library

How many different LIBNAMEs are involved? What are the rules for changing the LIBNAMEs? If these two questions can't be answered cleanly then you may have some problems.

If there are only a few LIBNAMES involved I might suggest moving the declarations to a common AUTOEXEC.SAS or included file than all users can share if that is practical in your environment.

Contributor
Posts: 74

SAS Script to edit sas programs in a library

Here is how I plan to change the libnames:

In old server: I have all the programs in the following library:

    libname old \\oldserver\\productionjobs

I need to change the above libname to the following:

libname new \\newserver\\production\\jobs

I only have the above mentioned libnames

Thanks so much for your reply.

Super User
Posts: 10,023

SAS Script to edit sas programs in a library

SAS program is only a txt file.You can read .sas file just as .txt file and use data step and tranwrd() function to change these libname statement.

Ksharp

Super Contributor
Super Contributor
Posts: 3,174

SAS Script to edit sas programs in a library

To simplify the edit activity, use a SAS macro variable to resolve the <libref> portion of your LIBNAME statement.  You can use a %INCLUDE statement to include / execute a SAS code member that contains the %LET statements needed to resolve the current-value of the <libref> portion.  And with that the actual LIBNAME statement and other code remains static.

Scott Barry

SBBWorks, Inc.

Ask a Question
Discussion stats
  • 4 replies
  • 145 views
  • 0 likes
  • 4 in conversation