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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.