BookmarkSubscribeRSS Feed
Akky1
Calcite | Level 5

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;

1 REPLY 1
sbxkoenk
SAS Super FREQ

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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

SAS Enterprise Guide vs. SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1120 views
  • 0 likes
  • 2 in conversation