Libname Test1 (C:\t1, C:\t2, C:\t3);
Filename Test2 (C:\t1, C:\t2, C:\t3);
Ques 1- In Libname, If all three folder do not exist then Libname gives WARNING but for filename there is no such warning generated. Why?
Ques 2- For libname/Filename, if member exists in multiple folder then which member would be refferred ? Example - Data1.sas7bdat with different columns exists in t1 and t2 folder then which Data1 would come in libname. I think it will take from t1 folder as it is written first. Please confirm whether order of folder name matters? Is the same concept applies on Filename.
Q1. You can use a filename to create a file, in this case it doesn't need to preexist to create a file.
I don't know the answer to Q2
Since a filename can be used to create a new file, SAS doesn't complain if no file is present at the time you define the file reference.
A library must be present at the time the libname is executed.
If you want to create new files/datasets, spanned definitions are a BAD IDEA. Don't do it.
And if you're not sure what is where, don't use them either. Be specific.
- Computers are dumb ("Computer sind doof" - Spliff, 1984)
Q2 is easy enough to test. What is the output from this program?
libname t1 "C:\t1"; libname t2 "C:\t2"; data t1.test; x = 'This is the data set in T1'; data t2.test; x = 'This is the data set in T2'; libname both ("C:\t1" "C:\t2"); title 'T1 is first'; proc print data=both.test; run; libname both clear; libname both ("C:\t2" "C:\t1"); title 'T2 is first'; proc print data=both.test; run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.