SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
CathyVI
Pyrite | Level 9

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.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register 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
  • 1226 views
  • 2 likes
  • 2 in conversation