02-22-2018 08:06 AM
When you define libname concatenation and you create a new table, this is saved in the first path (if the path has available space). Is possible to configure that use the path with more free space?
Libname test ('/path1' '/path2');
The table "new" is created by default in "/path1", the first path used in libname statement.
02-22-2018 09:18 AM
No, I can't think of any built-in features in SAS that support this function. And there is a possibility that you won't be able to do at all depending on your SAS deployment (eg. Admin may not let you call for OS command). . You will need to pre-check the available storage space for each ‘path’ by calling OS commands, again, depending on the OS, the commands are different, pipe and parse the useful information back to SAS, do the comparison, then realign the order in your final Libname statements. As you can see, it could get to certain level of complexity and Macro language will likely to be required.
02-22-2018 09:22 AM
I don't believe what you're asking for is possible, using libname concatenation
What you might be able to do instead is create multiple libraries, one concatenating all your relevant inputs together and the rest referring to each component of the concatenation. From there, I found this pre-written macro program that you might be able to customize to calculate free space for each particular folder.
02-22-2018 09:44 AM
The problem is I need to use two filesystem as one. For some operation system limitation, it's not possible to have a big filesystem, so I have two but I needed working as one.
I understand that, in library concatenation, when a SAS file is opened for output, it is created in the first path that is listed in the concatenation. Even if there is a file with the same name in another part of the concatenation. This is a huge problem for me.
libname test ('/path1' '/path2');
In this case, even if CLASS already exists in '/path2', instead to recreate the table, a new version of the table is created in '/path1'. There is workaround for this behaviour? Any suggestion?
02-22-2018 03:58 PM
Ok, I see what you are facing. Hopefully the following code can mitigate some of your pain. You can, however, realize the same functionality by using Macro, but I find it is easier to write/debug code in the combination of data step and call execute().
%let tname=CLASS; /*the table name you choose to create downstream*/ /*put your multiple path in a data set, you will find it is so much easier to manuver later on*/ data path; infile cards truncover; input path $100.; cards; '/path1/' '/path2/' ; data _null_; set path end=last; length cat $ 200; retain cat; cat=catx(' ',path); /*for _big library assignment*/ /*create dynamic libraries for each path*/ call execute ( 'libname ' ||"_" ||left(put(_n_,best.)) ||" " ||path ||";" ) ; if last then do; /*identify the libraries that have the table with the same name*/ call execute ( 'proc sql; create table tmp as select libname from dictionary.tables where memname=' ||'"' ||STRIP("&TNAME.") ||'"' ||'; QUIT;' ); /*delete those tables if they exist*/ CALL EXECUTE (' data _null_; set tmp nobs=nobs; if nobs>0 then call execute ( "proc datasets library=" ||libname ||";" ||"delete &TNAME.;" || "run;" ); run; '); /*assign the concatenated library*/ call execute ( 'libname _big (' ||cat ||');' ); END; run;
02-22-2018 10:01 PM
>There is workaround for this behaviour? Any suggestion?
I'd suggest deleting the table before creating a new one.
One deletion call (proc delete or proc datasets or proc sql+drop) will only delete one instance.
So you need as many deletions as there are copies of a table in each of the paths, if that makes sense.
This macro will do this.
Here, it performs two deletions;
libname A 'c:\temp'; libname B (A WORK); data A.T WORK.T; run; %macro fulldelete(table); %do %while( %sysfunc(exist(&table)) ); proc delete data=&table.; run; %end; %mend; %fulldelete(B.T);
02-22-2018 04:28 PM
LIBNAME LIB1 "/path1";
LIBNAME LIB2 "/path2";
LIBNAME LIB (LIB1 LIB2);
In this case the output will by default go into LIB1. If you want to sent the output to more free space then use SASHELP.VTABLE and calculate the filesize in each LIB1 and LIB2 and write a logic to send to more free space library.