Hello guys.
I am running a DS2 procedure and reading an in-memory table. Code is similar to the structure below.
%LET SESSION=table2pro;
%LET ACASLIB=PUBLIC ;
cas &SESSION sessopts=(caslib=&ACASLIB. timeout=1800 locale="en_US");
libname &ACASLIB. cas;
caslib _ALL_ list ;
caslib _ALL_ assign ;
proc Ds2;
DS2_OPTIONS divbyzero=ignore;
DS2_OPTIONS TYPEWARN;
DATA &ACASLIB..output_M1 / overwrite=yes;
method run();
SET &ACASLIB..input_M1;
/* OTHER STATEMENTS HERE*/
/* OTHER STATEMENTS HERE*/
I get an error like:
DS2 either runs completely in CAS or completely on the Compute Server (Base SAS). It can only access CAS tables when running in CAS. To execute DS2 in CAS using PROC DS2, you must specify the name of the CAS session in which you want to execute as an option on the PROC DS2 statement. This should do it for you:
%LET SESSION=table2pro;
%LET ACASLIB=PUBLIC ;
cas &SESSION sessopts=(caslib=&ACASLIB. timeout=1800 locale="en_US");
/* other sas code as desired */
proc ds2 sessref=&SESSION;
/* other DS2 code here*/
run;
quit;
Make sure your DS2 programs reference tables using caslib.table notation instead of libref.dataset notation. For example, in your code you assigned the libref ACASLIB to the PUBLIC caslib. In DATA step you reference acaslib.table, but running ds2 in CAS you reference public.table.
DS2 either runs completely in CAS or completely on the Compute Server (Base SAS). It can only access CAS tables when running in CAS. To execute DS2 in CAS using PROC DS2, you must specify the name of the CAS session in which you want to execute as an option on the PROC DS2 statement. This should do it for you:
%LET SESSION=table2pro;
%LET ACASLIB=PUBLIC ;
cas &SESSION sessopts=(caslib=&ACASLIB. timeout=1800 locale="en_US");
/* other sas code as desired */
proc ds2 sessref=&SESSION;
/* other DS2 code here*/
run;
quit;
Make sure your DS2 programs reference tables using caslib.table notation instead of libref.dataset notation. For example, in your code you assigned the libref ACASLIB to the PUBLIC caslib. In DATA step you reference acaslib.table, but running ds2 in CAS you reference public.table.
Thank you very much. That resolved the issue.
The last part I didn't quite get it.
Isn't it the same if I write &ACASLIB or PUBLIC inside DS2 code?
Considering &ACASLIB will resolve to PUBLIC.
Yes, &ACASLIB will resolve to PUBLIC here. I don't know why, but I thought ACASLIB was a LIBREF for the PUBLIC caslib. That code would have looked like this:
libname acaslib cas caslib=public;
Instead of what you ACTUALLY wrote 🙄. So all I really needed to talk about was the SESSREF= option. Sorry for the confusion.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.