BookmarkSubscribeRSS Feed
MohamedS
Obsidian | Level 7
Hi,

Do anyone know, how to build a library one time such in batch or config and to be shared through all sas components and modules without typing libname statement again?
1 REPLY 1
deleted_user
Not applicable
The libname definition exists to a SAS session as long as "sas ... " is running. As soon as the SAS session goes away, the libname definition goes away for that session.

BUT,

the libname can be automated through a couple different mechanisms that I know of so that it is not necessary to code it into every SAS program:

1) autoexec.sas can be used to issue commonly used libname definitions.

2) A metatdata server. It is possible to have a sas session connect to a metadata server and for the server to then automatically provide access to libraries. Even batch SAS can do this, not just with EG and other SAS products.

We, where I am, have PC SAS on our local workstations and access to multiple SAS servers. We have an autoexec.sas file on our local PC's that points to another "autoexec.sas" file on our common server, which then %include's a file we call "LibaryDefinitions.sas". The autoexec's are specific to each user, but the LibraryDefinitions.sas file is common to all of our group's users and programs. It defines commonly used filenames libnames and options. This provides a single point of reference and maintenance, and insures commonality and portability. It also is a productivity aid since we don't have to code all that stuff every time into our programs. And, due to many issues (local and with SAS) we use it for our Logical EG servers as well, instead of the MetaData Libraries; although, I suppose with better administration, we could make more use of the MetaData Server.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1282 views
  • 0 likes
  • 2 in conversation