Hi.
Peter.C
I think your code is right.
But we have hundreds of librarys ,It is hard for me to apply the code to the library separately.Fortunately I have solution just as I said in the last post.
I also talk to SAS Technology ,they gave me two methods, one of two is very useful which use SPDS API in data step to sum the size of each library.
And I post these ,hope to help somebody.
[pre]
/***
/* This program uses the SAS Open Metadata API data step functions to query
/* the metadata repository and return a list of all libraries and their
/* associated directory or database schema. The results are returned to a
/* SAS data set in the WORK library.
/*
/* Modify the code to generate the results in a form useful to you, such as
/* a simple listing via PROC PRINT.
/*
/* Modify the Meta* options to supply correct connection parameters to the
/* metadata server that contains the user information. The METAUSER should
/* be a user who has read permission to the metadata objects being queried,
/* such as the Unrestricted (e.g. sasadm) user.
***/
/*Connect to the metadata server*/
options metaserver="your.metadata.server"
metaport=8561
metauser="sasadm@saspw"
metapass="sasadmpw"
metarepository="Foundation"
metaprotocol=BRIDGE;
/* Begin query to metadata server for SAS Library objects */
data metadata_libraries;
length liburi upasnuri $256 name Description $128 type id $17 libref engine $8 path mdschemaname schema $256;
keep name libref engine path mdschemaname schema Description;
call missing(liburi,upasnuri,name,engine,libref,Description);
/* Get each Library object */
nlibobj=1;
librc=metadata_getnobj("omsobj:SASLibrary?@Id contains '.'",nlibobj,liburi);
/* For each library, retrieve the libref, engine, path */
do while (librc>0);
/* Get Library attributes */
rc=metadata_getattr(liburi,'Name',name);
rc=metadata_getattr(liburi,'Engine',engine);
rc=metadata_getattr(liburi,'Libref',libref);
rc=metadata_getattr(liburi,'Desc',Description);
/* Get the Directory and DatabaseSchema object
associated with this library via a
UsingPackages association*/
n=1;
uprc=metadata_getnasn(liburi,'UsingPackages',n,upasnuri);
/* We found a UsingPackages association */
if uprc > 0 then do;
/* Determine object type */
call missing(type,id,path,mdschemaname,schema);
rc=metadata_resolve(upasnuri,type,id);
if type='Directory' then do;
/* Get the path and output the record */
rc=metadata_getattr(upasnuri,'DirectoryName',path);
output;
end; /*if type='Directory'*/
else if type='DatabaseSchema' then do;
/* Get the schema and output the record */
rc=metadata_getattr(upasnuri,'Name',mdschemaname);
rc=metadata_getattr(upasnuri,'SchemaName',schema);
output;
end; /*if type='DatabaseSchema'*/
/*Check to see if there are any more Directory objects*/
n+1;
uprc=metadata_getnasn(liburi,'UsingPackages',n,upasnuri);
end; /*if uprc > 0*/
/*Look for another library*/
nlibobj+1;
librc=metadata_getnobj("omsobj:SASLibrary?@Id contains '.'",nlibobj,liburi);
end; /*do while (librc>0)*/
run;
proc print data=metadata_libraries;
var name description;
run;
[/pre]
Or another way ,but it is only suited for a single library.
[pre]
libname spdslib sasspds 'class' server=chloeyu.5400 user='chloe' password="xxxxxxx" aclspecial=yes;
proc spdo lib=spdslib ;
spdscmd 'spdsls -info -s -verbose D:\test\spds\meta';
quit;
58 proc spdo lib=spdslib ;
NOTE: Enter "?;" to get info on all the SPDO commands.
Enter "SPDSMAC;" to get list and setting of all SPD macros.
59 spdscmd 'spdsls -info -s -verbose D:\test\spds\meta ';
DPF_SIZE IDX_SIZE MDF_SIZE NUMOBS OBSLEN SEGSIZE PARTSIZE CMP ENC CLM TABLE
760 0 26780 19 40 8192 268435200 NO NO NO AA
8 0 26476 1 8 8192 33554432 NO NO NO NEW
260000000 0 26552 5000000 52 8192 33552896 NO NO NO PP60
quit;
NOTE: “PROCEDURE SPDO”所用时间(总处理时间):
实际时间 0.85 秒
CPU 时间 0.01 秒
DPF_SIZE is the size of all the dpf files, IDX_SIZE is the index size, MDF_SIZE is the metadata file size.
on spds server host, you can run following code to get a file of the table size list:
spdsls -info -s -verbose D:\test\spds\meta > d:\1.txt
then you can read the data into SAS and summary to get the library size.
[/pre]
BTW. I will have holidays for the sake of Trandition Spring Festival in China.
Maybe I will not appear in this forum for a several days.
And Happy New Year to Peter.C.
Ksharp