Hello,
I have a CCW folder with multiple years CCW - 2006 to 2021. Within each year folder, I have multiple sas data files. I would like to have all these files referenced in a single libref so that when I lunch the libref, i can work on any sas files in any year. For example, I tired something like this but did not work. I am using sas studio.
%let path= ('/_ABC_CDB_SASDS/CCW/2006', '/_ABC_CDB_SASDS/CCW/2007');
%macro setdelim;
%global delim;
%if %index(&path,%str(/)) %then %let delim=%str(/);
%else %let delim=%str(\);
%mend;
%setdelim
libname ccw "&path";
proc contents data=ccw.bcarclms2006; run;
proc contents data=ccw.bcarclms2007; run;
Obviously cannot test your code as we don't have your file set up.
You want to make sure that each element of a file path starts at either a drive letter (Windows) or the root mount point for other storage. Otherwise the paths are relative to where the SAS session is executing from.
Also, the path has to be as seen by your SAS session server if you are using anything other than a purely local machine SAS install.
Note that if any of the data set names appear in more than one folder you will only see one in the library and which one may not be predictable.
What did your SAS log report?
For starters you don't need double quotes so try this:
%let path= ('/_ABC_CDB_SASDS/CCW/2006', '/_ABC_CDB_SASDS/CCW/2007');
libname ccw &path;
@SASKiwi Thank you. I am familiar with the process that you shared. Please is there another way to do it.
@CathyVI - I suggest you first try defining a LIBNAME for one folder. Does that work? You can concatenate two existing libraries into a third one:
libname L1 '/Folder1';
libname L2 '/Folder2';
libname L3 (L1 L2);
Also, there was an error in your example that I didn't spot until now (remove comma between the paths):
%let path= ('/_ABC_CDB_SASDS/CCW/2006' '/_ABC_CDB_SASDS/CCW/2007');
libname ccw &path;
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.