I am working on a script that will scan my caslibs and will report to me the datasets that are not loaded. The code works (email portion lacking). However, I can only "print" my results. I need to get them into work.temp so that I can query them for email. Below is my code. I have tried everything that I can think of, but I cannot find a way to do an insert inside of my proc cas block.
Try something like this:
proc datasets library=work kill; run; quit;
cas mySession;
proc cas;
%let myCaslib = PUBLIC;
/* Lists the files in a caslib's data source. */
table.fileinfo result=fileresult / caslib="&myCaslib";
files=findtable(fileresult);
saveresult files dataout=work.files;
table.tableinfo result=tableresult / caslib="&myCaslib";
tables=findtable(tableresult);
saveresult tables dataout=work.tables;
quit;
cas mysession terminate;
proc sql;
create table work.notloaded as
select "&myCaslib" as myCaslib
,f.Name as myFileName
,catx(" ",f.name,": Dataset not loaded") as myMessage
from work.files as f
where f.Name not in (select SourceName from work.tables);
quit;
Try something like this:
proc datasets library=work kill; run; quit;
cas mySession;
proc cas;
%let myCaslib = PUBLIC;
/* Lists the files in a caslib's data source. */
table.fileinfo result=fileresult / caslib="&myCaslib";
files=findtable(fileresult);
saveresult files dataout=work.files;
table.tableinfo result=tableresult / caslib="&myCaslib";
tables=findtable(tableresult);
saveresult tables dataout=work.tables;
quit;
cas mysession terminate;
proc sql;
create table work.notloaded as
select "&myCaslib" as myCaslib
,f.Name as myFileName
,catx(" ",f.name,": Dataset not loaded") as myMessage
from work.files as f
where f.Name not in (select SourceName from work.tables);
quit;
Just use the result set from table.caslibInfo and your original DO OVER technique to create a new work.xxx table for each caslib, then use PROC APPEND to the individual work datasets to a master list.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.