BookmarkSubscribeRSS Feed
CathyVI
Lapis Lazuli | Level 10

Hi,

I have a folder with two levels. The first level has 20 second level folders. I have sasfiles in each of the second level and will like to create a single libname for them. How do I do that? 

For example: 

First level folder : /_U/N/RC/Proj/SAS

Second level folder : /_U/N/RC/Proj/SAS/data1/a.sas7bdat

                                 /_U/N/RC/Proj/SAS/data2/b.sas7bdat

                                 /_U/N/RC/Proj/SAS/data3/c.sas7bdat

                                 /_U/N/RC/Proj/SAS/data4/d.sas7bdat

When I write a libname to reference all the second level files using the  

libname x "/_U/N/RC/Proj/SAS"; run;

its not working and I do not want to go through the pain of writing 20 libnames and putting all the libref in  another single libname or is that what I have to do? 

1 REPLY 1
ballardw
Super User

Note: BDAT files should not be part of a "libname" they are the data sets.

A libname statement to reference multiple folders needs to list them. One way is below. Note the ( ) around the list.

libname x ("/_U/N/RC/Proj/SAS/data1" "/_U/N/RC/Proj/SAS/data2"
           "/_U/N/RC/Proj/SAS/data3" "/_U/N/RC/Proj/SAS/data4" 
          ); 

another would be assign a different libname to each folder and then create composite library. Assuming you created libraries named Lib1 through lib4 , one for each folder. Then the library All would include all of them.

libname all (lib1 lib2 lib3 lib4);

Caution: duplicate data set names in multiple folders will be difficult to work with.

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore Now →
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1988 views
  • 2 likes
  • 2 in conversation