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

Hello programmers,

 

I am trying to wrap my head around libref and library.

Any help would be appreciated

Libname nsch "C:\Users\Aba\Box\NSCH\nsch1617combined_drc";
Libname library "C:\Users\Aba\Box\NSCH\nsch1617combined_drc";

PROC FORMAT LIBRARY=LIBRARY;
/*Topical*/

.The error message was that libref and library are the same physical address. Please in what formats should the libref and library be in? 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
It's fine, it's not an error, it's a warning or note I believe just to let you know that two definitions point t the same location. This means that anything written to nsch is also written to library so it's not a super useful thing to do in most cases.

View solution in original post

7 REPLIES 7
Reeza
Super User
It's fine, it's not an error, it's a warning or note I believe just to let you know that two definitions point t the same location. This means that anything written to nsch is also written to library so it's not a super useful thing to do in most cases.
ChuksManuel
Pyrite | Level 9

Thank you for the response

Krueger
Pyrite | Level 9

Libref is used to reference a library. 

 

In your code above nsch is useless as it is being overwritten by library why are they both pointed to the same Physical location?

ChuksManuel
Pyrite | Level 9

Thanks! That was helpful

FreelanceReinh
Jade | Level 19

Hello @ChuksManuel,

 

I wouldn't say it's useless to create the second libref because libref library has a special meaning when it comes to searching format catalogs (see FMTSEARCH= system option). It's not just an alias for nsch (in your case).

 

To avoid the note "... refers to the same physical library as ..." you can use this syntax

libname library (nsch);

referring to the existing libref nsch.

ChuksManuel
Pyrite | Level 9

Thanks!

Kurt_Bremser
Super User

Just to dig a little deeper into why one uses the special name "library": if you want to send data to other SAS users that contain custom formats, defining those formats in the catalog library.formats and storing the datasets in the same directory enables you to cport the whole library into one blob, and when the receivers also use "library" when they cimport the blob, the formats will automatically be there and usable.

 

Note that you should still send the format code along in a .sas file.

hackathon24-white-horiz.png

Join the 2025 SAS Hackathon!

Calling all data scientists and open-source enthusiasts! Want to solve real problems that impact your company or the world? Register to hack by August 31st!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 7 replies
  • 3558 views
  • 10 likes
  • 5 in conversation