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

Let's say I have 10 SAS programs that each have the following at the top:

Libname MyLib "E:\MySASFiles";

Is there a way to only change the directory name in one of the programs and let the rest update auto-magically? I'm thinking %Include but i'm not familiar enough with this option. Any Hints?

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Create a single .sas program that assigns libs.

Then put a %include at the top of your programs that includes the file above.

But that assumes you're not using the same name for diff libraries in different programs which I've also seen.

View solution in original post

4 REPLIES 4
Reeza
Super User

Create a single .sas program that assigns libs.

Then put a %include at the top of your programs that includes the file above.

But that assumes you're not using the same name for diff libraries in different programs which I've also seen.

jwillis
Quartz | Level 8

Another option is to make 'E:\MySASFiles' a macro value and change all your libname statements to be

Libname MyLib "&mylib."; then, in the first program code %global mylib; %let mylib = E:\MySASFiles;


ballardw
Super User

For the libraries I use all of the time I have assignments in my autoexec.sas. I know that is "old school" BUT if I reconfigure my machine I only need to change the libname in one place.

I do not repeat the library assignments in each program.

Ksharp
Super User

I would like to use CALL EXECUTE .

data fold;

input f : $40.;

cards;

c:\x

d:\d

;

run;

data _null_;

set fold;

call execute('%let f='||f ||' ; ');

call execute('%include a1 ;  ');

call execute('%include a2 ;  ');

call execute('%include a3 ;  ');

call execute('%include a4 ;  ');

run;

and change libname statement in all of program.

Libname MyLib " &f ";



Ksharp

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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