/* most of the code is somewhere borrowed, can't remember the exact site anymore */
options nonotes;
cas adminsession;
caslib _all_ assign;
proc cas;
/* need to be a super user */
accessControl.assumeRole / adminRole="superuser";
accessControl.accessPersonalCaslibs;
table.caslibinfo result=fileresult;
casliblist=findtable(fileresult);
/* loop caslibs */
SumDataSize=0;
SumCompressedSize=0;
SumMappedMemory=0;
do cvalue over casliblist;
if cvalue.name!=: 'demoCASUSER' then
do;
/* only look at caslibs that contain CASUSER */
table.tableinfo result=tabresult / caslib=cvalue.name;
tablelist=findtable(tabresult);
x=dim(tablelist);
if x>1 then
do;
/* there are tables available */
do tvalue over tablelist;
/* loop all tables in the caslib */
/* table.droptable / caslib="casuser" name="tableinfo"; */
table.tabledetails result=r / caslib=cvalue.name name=tvalue.name;
/* table.tableinfo / caslib=cvalue.name name=tvalue.name; */
val=findtable(r);
saveresult val caslib="CASUSER" casout="tableinfo" replace;
do xvalue over val;
/* */
/* print (xvalue.DataSize); */
/* SumDataSize=0 ; */
SumDataSize=SumDataSize+xvalue.DataSize;
SumCompressedSize=SumCompressedSize+xvalue.CompressedSize;
SumMappedMemory=SumMappedMemory+xvalue.MappedMemory;
/* print cvalue.name, tvalue.name, xvalue.CompressedSize, "SumDataSize:" SumDataSize; */
print "INFO-001: LIBRARY: " cvalue.name " :tabel :" tvalue.name
":DataSize :" xvalue.DataSize ":CompressedSize :"
xvalue.CompressedSize ":AllocatedMemory : " xvalue.AllocatedMemory
": Creator : " tvalue.creator;
/* print xvalue; */
/* print tvalue; */
/* print cvalue; */
end;
/* print(r); */
/* describe(r); */
/* data CASUSER.tableinfo_total ; */
/* set CASUSER.tableinfo_total CASUSER.tableinfo; */
/* table.append / */
/* source={caslib='CASUSER',name='tableinfo'} */
/* target={caslib='CASUSER',name='tableinfo_total'}; */
end;
/* loop all tables in the caslib */
end;
/* there are tables available */
end;
/* only look at caslibs that contain CASUSER */
end;
/* loop caslibs */
print "INFO-001:SumDataSize :" round(SumDataSize/1024/1024) "MB";
print "INFO-001:SumCompressedSize :" round(SumCompressedSize/1024/1024)
"MB";
print "INFO-001:SumMappedMemory : " round(SumMappedMemory/1024/1024) "MB";
accessControl.dropRole / adminRole='superuser';
quit;
cas adminsession terminate;