SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sujaybshha
Fluorite | Level 6

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:

ERROR: There is no session-scope table GL_PERIODS in caslib Public of Cloud Analytic Services.
ERROR: The action stopped due to errors.
 
Please let me know what would be the fix. Much Thanks!
 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SASJedi
Ammonite | Level 13

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

 

 

Check out my Jedi SAS Tricks for SAS Users

View solution in original post

3 REPLIES 3
SASJedi
Ammonite | Level 13

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

 

 

Check out my Jedi SAS Tricks for SAS Users
sujaybshha
Fluorite | Level 6

Thanks, I am using Viya 3.5, so table.partition is the command I was looking for. 

BenRyan
SAS Employee

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.

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 3766 views
  • 4 likes
  • 3 in conversation