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));
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: