BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
andreas_zaras
Pyrite | Level 9

Hello,

 

I have created a data set in the academic cas library in SAS Viya for learners using a data step (i also promoted it). I want to replace the data set with a new one. How can i delete it from the academic cas?

 

Thanks in advance,

 

Andreas

1 ACCEPTED SOLUTION

Accepted Solutions
HarrySnart
SAS Employee

Hi @andreas_zaras 

 

With regards to how to delete a table from a CAS library, I'd recommend you look at PROC CASUTIL, specifically the DROPTABLE function. https://go.documentation.sas.com/doc/en/vdmmlcdc/1.0/casref/p14fpceaxx8pz9n1id0wrgj92mrt.htm 

 

When a table is promoted in CAS it is a global scope table, CAS does not allow you to implicitly replace the dataset to protect the dataset. That said, if you need to replace the data all you need to do is add the REPLACE option.

 

Here is some simple example code: 

*Add CASLIB to session;
libname casuser cas;

*Load data into CAS;
data casuser.cars(promote=yes);
set sashelp.cars;
run;

*Replace data using datastep;
data casuser.cars(replace=yes);
set sashelp.cars(where=(make='Audi'));
run;

*Drop table using PROC CASUTIL;
proc casutil;
droptable casdata='cars' incaslib='casuser';
run;

*Test table does not exist;
proc print data=casuser.cars;run;

Hope this helps

 

Thanks,

Harry

View solution in original post

3 REPLIES 3
HarrySnart
SAS Employee

Hi @andreas_zaras 

 

With regards to how to delete a table from a CAS library, I'd recommend you look at PROC CASUTIL, specifically the DROPTABLE function. https://go.documentation.sas.com/doc/en/vdmmlcdc/1.0/casref/p14fpceaxx8pz9n1id0wrgj92mrt.htm 

 

When a table is promoted in CAS it is a global scope table, CAS does not allow you to implicitly replace the dataset to protect the dataset. That said, if you need to replace the data all you need to do is add the REPLACE option.

 

Here is some simple example code: 

*Add CASLIB to session;
libname casuser cas;

*Load data into CAS;
data casuser.cars(promote=yes);
set sashelp.cars;
run;

*Replace data using datastep;
data casuser.cars(replace=yes);
set sashelp.cars(where=(make='Audi'));
run;

*Drop table using PROC CASUTIL;
proc casutil;
droptable casdata='cars' incaslib='casuser';
run;

*Test table does not exist;
proc print data=casuser.cars;run;

Hope this helps

 

Thanks,

Harry

andreas_zaras
Pyrite | Level 9
Thanks for your answer! It works fine i used both replace and promote at the same time and everyting is fine,

Thanks!
MAGG
Obsidian | Level 7

Unfortunately there seem  a misunderstanding in the given example.

 

The proc print works fine en does not give an error at all!

 

This is because the second cars-table is a not a global-scope cas-table but a session-scope cas-table! The cas-table is therefore not replaced. The drop-table statement drops the session-scope table. The unalterd global-scope table still exists!!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 5036 views
  • 2 likes
  • 3 in conversation