I use the following options when creating a CAS table with the Query step in a SAS Studio flow:

The generated code correctly performs the droptable, create table, and save casdata (replace) actions.
/* Delete existing session-scope and global-scope tables cas.cas_table by using two delete statements. */
proc casutil;
droptable casdata="cas_table" incaslib="cas" quiet;
droptable casdata="cas_table" incaslib="cas" quiet;
quit;
PROC SQL;
CREATE TABLE cas.cas_table (promote=yes) AS
SELECT
...
FROM
WORK.t111 t1
;
QUIT;
RUN;
/* Create a permanent copy of the in-memory table cas.cas_table */
proc casutil incaslib="cas" outcaslib="cas";
save casdata="cas_table" replace;
quit;
However, a problem occurs when a user opens a Visual Analytics report at the same time the table‑update script is running:
- The script deletes the CAS table from memory.
- A user opens the VA report.
- VA automatically loads the previous physical table from disk back into memory.
- The script then attempts to create and promote the table, but VA has already promoted it, causing the error:
“The target table table_name of the promotion already exists. Please specify a different name.”
What is the best way to avoid conflicts between SAS Studio code and Visual Analytics? Scheduling the job outside business hours is not an option.