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));
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
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.