- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am trying to promote a session scope CAS table. The table needs to be global scope but in CAS only. Here is my code:
cas Public sessopts=(caslib='Public' timeout=1800 locale="en_US");
/* Create SAS librefs for existing caslibs so that they are visible in the SAS Studio Libraries tree. */
/* Recommend to use the 'Public' as the libname */
libname Public cas caslib ='Public';
PROC CASUTIL;
droptable casdata='GL_PERIODS_inCas' incaslib="Public" quiet;
promote casdata='GL_PERIODS' incaslib="PUBLIC" casout = 'GL_PERIODS_inCas' outcaslib="PUBLIC";
quit;
The above code generates the following error:
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Assuming you have the requisite permissions to promote & delete tables, here is the trouble as I see it:
After your DROPTABLE statement deletes the table named GL_PERIODS_inCAS, the CAS table you want to put in its place (GL_PERIODS) doesn't yet exist. This is what is causing the error message:
ERROR: There is no session-scope table GL_PERIODS in caslib Public of Cloud Analytic Services.
You need to create a session-scope table named GL_PERIODS in the Public caslib before you begin this process. Once you have the session-scoped table available in Public, you can more easily accomplish your goal using CASL code (instead of PROC CASUTIL). Something like this should work:
proc cas;
table.dropTable /
caslib="public"
,name="GL_PERIODS_inCAS"
,quiet=TRUE
;
/* For Viya 3.4 and 3.5, use table.partition to copy the table */
table.partition /
table={caslib="public",name="GL_PERIODS"}
,casout={caslib="public",name="GL_PERIODS_inCAS",promote=TRUE}
;
/* For Viya 2020.1 and beyond, use table.copyTable */
table.copyTable /
table={caslib="public",name="GL_PERIODS"}
,casout={caslib="public",name="GL_PERIODS_inCAS",promote=TRUE}
;
quit;
After verifying that all went well, you can drop the session-scoped table, or just disconnect from CAS.
May the SAS be with you!
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Assuming you have the requisite permissions to promote & delete tables, here is the trouble as I see it:
After your DROPTABLE statement deletes the table named GL_PERIODS_inCAS, the CAS table you want to put in its place (GL_PERIODS) doesn't yet exist. This is what is causing the error message:
ERROR: There is no session-scope table GL_PERIODS in caslib Public of Cloud Analytic Services.
You need to create a session-scope table named GL_PERIODS in the Public caslib before you begin this process. Once you have the session-scoped table available in Public, you can more easily accomplish your goal using CASL code (instead of PROC CASUTIL). Something like this should work:
proc cas;
table.dropTable /
caslib="public"
,name="GL_PERIODS_inCAS"
,quiet=TRUE
;
/* For Viya 3.4 and 3.5, use table.partition to copy the table */
table.partition /
table={caslib="public",name="GL_PERIODS"}
,casout={caslib="public",name="GL_PERIODS_inCAS",promote=TRUE}
;
/* For Viya 2020.1 and beyond, use table.copyTable */
table.copyTable /
table={caslib="public",name="GL_PERIODS"}
,casout={caslib="public",name="GL_PERIODS_inCAS",promote=TRUE}
;
quit;
After verifying that all went well, you can drop the session-scoped table, or just disconnect from CAS.
May the SAS be with you!
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, I am using Viya 3.5, so table.partition is the command I was looking for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
To promote an existing session-scoped in-memory CAS table you need to run the promote action within the same CAS session in which the session-scoped table exists. In this case you are creating a new session and running with that new session so the promote cannot see the session-scoped table (which is in a different session).
If the CAS session in which you loaded the session-scoped table is still active then you can obtain its CAS session ID and use that to connect your code to the same session. Refer to: https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/casref/n0z3r80fjqpobvn1lvegno9gefni.htm#p1... and "Example 8: Connect to an Existing Session". You would want to do something along the lines of:
cas mysess uuid="ca683ddf-fe18-3c48-a04e-45718220976d";
If the CAS session where you loaded the session-scoped table is no longer active, then your session-scoped table will have been unloaded from memory at the time the CAS session was terminated. In that case, you may want to combine your code that loads the session-scoped table (which I don't see here) and your code that promotes the table into the same snippet/program as that will have both the loadTable and the promote running in the same CAS session. Thus there will be no issue with the promote locating your session-scoped in-memory table.