sas

Find out properties of all tables stored on CAS (SAS)


I am working with SAS Viya/CAS.

I first entered the following command:

proc cas;
table.caslibInfo;
quit;

From here, I see a table with different folder names. Some of the paths look like this:

/disk/data/sas/zzz123/home1/...
/disk/data/sas/zzz123/home2/...
/disk/data/sas/zzz123/home3/...

I want to find out the name of every table in zzz123 (the server name) and the size of each table.

I am new to SAS. I tried using something like this for a specific table:

proc cas;
table.tableDetails/caslib = "some name" name = "table1";
quit;

But is there something in SAS that I can do to find out the storage and tables for everything on the CAS server?

%macro get_all_table_details(caslib);
proc cas;
    table.tableInfo / caslib="&caslib";
    

    table.tableDetails / caslib="&caslib";
quit;
%mend;

%get_all_table_details(a);

Solution

  • This will allow you to print the size of every backing store (file) on every CASLIB on the server:

    proc cas;
        table.caslibInfo result=c;
    
        do caslib over c.CASLibInfo[,'Name'];
            table.fileInfo / 
                caslib=caslib 
            ;
        end;
    quit;
    

    You can save this to a dictionary if needed and then save it as a table with saveresult. Unfortunately for in-memory size of tables loaded to CAS, tableDetails doesn't take only a CASLIB argument. You will need to use the results from tableInfo to loop over each table loaded to the CASLIB and pass it to tableDetails. For example:

    proc cas;
        table.caslibInfo result=c;
    
        do caslib over c.CASLibInfo[,'Name'];
            table.fileInfo / 
                caslib = caslib 
            ;
    
            table.tableInfo result=t / 
                caslib = caslib
            ;
    
            do table over t.tableInfo[,'Name'];
                table.tableDetails / 
                    caslib = caslib
                    table  = table
                ;
            end;  
        end;
    quit;