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.
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.)
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.)
Thanks, ReelanceReinhard!! I've been searching for that for quite awhile. This will be very helpful!
Gary
Thank you for sharing. Learned something new today. 🙂
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));
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.