BookmarkSubscribeRSS Feed

Tired of deleting temporary CAS tables? Let CAS do it for you.

Started ‎11-19-2021 by
Modified ‎11-19-2021 by
Views 4,804

The memory in your CAS environment is a precious commodity and it’s often at a premium.  Having as much available memory in your CAS environment is not only important but also essential to your daily operations.  This is especially true in a Viya environment with many users.  Knowing you have enough memory in CAS to load your tables is beneficial and avoids the need for CAS to page parts of your tables between memory and disk when code is executing.

 

We all work with temporary tables that we have no use for after the processing is complete.  Unlike foundation SAS, CAS doesn’t have a work area.  Any table you load into CAS and don’t promote stays in memory until you delete it, or your CAS session is terminated.  It’s always a good idea and a best practice to eliminate these temporary tables when you are finished with them.  This helps keep as much available memory in your environment.  There are many options available to delete these temporary tables.  PROC DELETE, PROC DATASETS, and the dropTable CAS action are all good choices.  In SAS Studio you can also right click on the table in the library tree and select “Delete”.  However, an alternative is to use the lifetime parameter on the CAS table during the load.  This parameter is available in the loadTable CAS action.  It’s a subparameter in the CasOut parameter.  Once the value of the lifetime parameter is met, the table will drop from memory.

 

In the following example, I’ve loaded the CARS data set from a path based caslib to my CASUSER caslib in CAS.  I’ve set a lifetime of 120 seconds so I can run a quick process.  The table will be removed from memory after 2 minutes and I don’t have to write any additional code to delete it or manually delete it.

 

briankinnebrew_0-1637339739385.png

 

After the table is loaded, I can refresh my library tree and the CARS table resides in the CASUSER caslib.  I can now run whatever processes I need to against this table.

 

briankinnebrew_1-1637339798489.png

 

After 2 minutes, I refresh my library tree again, and the table has been dropped from memory.

 

briankinnebrew_2-1637339837925.png

 

The lifetime parameter is also available in the copyTable CAS action.

Consider using this technique when managing your temporary tables and keeping free memory at a maximum.  Happy coding!

Comments

thanks Brian, great post that I guided my class to, when they questioned the value of dropping tables

Version history
Last update:
‎11-19-2021 02:22 PM
Updated by:
Contributors

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!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags