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

Is it possible to assign one libref to another without specifying the path twice?  For example, something like:

libname xxx 'C:\folder_a';

libname yyy xxx;

 

instead of:

libname xxx 'C:\folder_a';

libname yyy 'C:\folder_a';

 

This would be very helpful for alot of situations in EG as well as modifying older programs.

 

Thanks.

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @gphunt,

 

Yes, this is possible by using parentheses around the second libref:

libname yyy (xxx);

 

(Edit: This is explained under "Form 4" in the documentation of the LIBNAME statement and mostly used for concatenating two or more libraries.)

View solution in original post

5 REPLIES 5
FreelanceReinh
Jade | Level 19

Hello @gphunt,

 

Yes, this is possible by using parentheses around the second libref:

libname yyy (xxx);

 

(Edit: This is explained under "Form 4" in the documentation of the LIBNAME statement and mostly used for concatenating two or more libraries.)

gphunt
Fluorite | Level 6

Thanks, ReelanceReinhard!!  I've been searching for that for quite awhile.  This will be very helpful!

Gary

novinosrin
Tourmaline | Level 20

Thank you for sharing. Learned something new today. 🙂

Tom
Super User Tom
Super User

Another possibility is to use the PATHNAME() function to find out where the other libref is pointing.

This probably will only work for simple examples where the first libref is pointing to physical folder(s).  

libname xxx 'C:\folder_a';
libname yyy "%sysfunc(pathname(xxx))";

Also watch out as the format of the result is different depending on how the original libname statement was constructed. When ( ) are used in the original then do not add the quotes around the returned value.

libname xxx ('C:\folder_a' 'C:\folder_b');
libname yyy %sysfunc(pathname(xxx));
gphunt
Fluorite | Level 6
Another great idea! Thanks, Tom.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 5 replies
  • 787 views
  • 0 likes
  • 4 in conversation