BookmarkSubscribeRSS Feed
CathyVI
Pyrite | Level 9

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;

 

5 REPLIES 5
ballardw
Super User

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.

 

Reeza
Super User
If you hardcode that approach with the correct file paths does it work?

If so, then the issue is with how you're generating the paths and you can work backwards and fix it.

If not, then the issue is with the connection to that location and you need to fix the file paths or ensure you have access.

What is the purpose of the setdelim? It isn't related to the rest of the code so having it in the middle there seems weird.
SASKiwi
PROC Star

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;

CathyVI
Pyrite | Level 9

@SASKiwi  Thank you. I am familiar with the process that you shared. Please is there another way to do it. 

SASKiwi
PROC Star

@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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 357 views
  • 4 likes
  • 4 in conversation