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));
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.