BookmarkSubscribeRSS Feed
DomUk
Fluorite | Level 6

Hello together,

 

i have a small question. Can I use the same libname for different folders. For reasons of clarity I have different folders (for example data preparation is one folder, the next is regression analysis...). Up to now I used the same libname , but I want to go sure that there is no problem with this methode.

 

Thank you

6 REPLIES 6
Shmuel
Garnet | Level 18

Are those folders used for input only? or both for input and/or output?

You can assign more than one folder to the libname:

libname <lib_name> ('path_1' 'path_2' ... 'path_n');

In such case, all outputs will be written to the first path assigned.

DomUk
Fluorite | Level 6
for both input and output. And the folders are on the same level. I used it in the following way:
libname data '/folders/myfolders/dataset';
libname data '/folders/myfolders/regression';

I think everything works fine, I just want to go sure
Reeza
Super User
In the case above the second libname would replace the first one and your data would only go to the last location. So I don't think it functions the way you want.
DomUk
Fluorite | Level 6
Hmm , but it revers to completely different folders, so when I open f.e. libname data '/folders/myfolders/regression'; then all the datasheets in the order "regression" are shown in sas. The datasheets in the folder "dataset" are not shown and not changed after I worked in sas.
Reeza
Super User
You can use the same name, but not at the same time.

If you have code as follows:

libname data '/folders/myfolders/data';
libname data '/folders/myfolders/regression';

proc sort data=data.myData;
run;

It's getting the data from the Regression folder, not the data folder. If you saved to the library, it would save only to the regression folder.

If you do something like below, it's valid, but confusing as hell and not recommended. Libnames can help you logically organize your process and files, and using the same name all the time removes that feature. But it's technically possible, like it's possible to use a hammer with a thumbtack.

libname data '/folders/myfolders/data';

proc sort data=data.myData out=sourceData;
run;

libname data;


libname data '/folders/myfolders/regression';

proc sort data=data.myData out=regData;
by ID;
run;

libname data;
DomUk
Fluorite | Level 6
Maybe one more information, I never worked parallel with both folders. So if I change something in the folder regression, I have only opened this folder in sas (libname data '/folders/myfolders/regression';) and not the other one.

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!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 659 views
  • 0 likes
  • 3 in conversation