Have used below to load a single table into CAS. How can I load all tables into CAS?
proc casutil;
load casdata="NATION" casout="NATION" outcaslib="snowLib" incaslib="snowLib";
quit;
Hello @Akky1 ,
There are 5 tables in the SASHELP library that have 'CITI' as the first 4 characters of the table name.
(SASHELP is there in every SAS installation by the way)
Below code loads all of them ( #5 ) in the PUBLIC CASLIB.
The 2nd data step writes code to drop the tables again from memory. Note the MOD option on the file statement in the 2nd data step. This way (with the MOD option) you add to the code already written to xyz temporary file instead of replacing xyz with new code.
cas mySession sessopts=(caslib=casuser timeout=1800 locale="en_US");
caslib _all_ assign;
PROC SQL noprint;
create table work.abc as
select memname
from dictionary.tables
where libname='SASHELP' and substr(memname,1,4)='CITI' and memtype='DATA';
QUIT;
filename xyz temp;
data _NULL_;
set work.abc end=last;
file xyz;
mn=trim(left(memname));
if _N_=1 then do; PUT 'proc casutil;'; end;
PUT 'load data=SASHELP.' mn ' outcaslib="PUBLIC" casout="' mn +(-1) '"; run;';
if last then do; PUT 'QUIT;'; end;
run;
data _NULL_;
set work.abc end=last;
file xyz MOD;
mn=trim(left(memname));
if _N_=1 then do; PUT 'proc casutil;'; end;
PUT ' droptable casdata="' mn +(-1) '" incaslib="PUBLIC" quiet; run;';
if last then do; PUT 'QUIT;'; end;
run;
%INCLUDE xyz / source2;
filename xyz clear;
PROC DATASETS library=PUBLIC NoList memtype=DATA;
delete CITI:; run;
QUIT;
*cas mySession terminate;
/* end of program */
Thanks,
Koen
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.