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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 6025 views
  • 2 likes
  • 3 in conversation