Hello there,
I am currently facing an issue with a SAS script involving the use of CAS tables, and I would greatly appreciate your insights to help resolve the problem.
The script creates a CAS session, defines a CAS library, creates a CAS table named "table" with a variable "text," defines a macro "test" that prints its parameter, and then applies the macro to each observation in the "table" CAS table using the call execute
routine.
Here is a simplified version of a script that executes a simple macreo:
cas mysess;
libname mycas cas;
data mycas.table;
length text $10;
input text $;
datalines;
This
is
a
sample
table
;
run;
%macro test(param);
%put param=¶m;
%mend test;
data mycas.test/sessref=mysess;
set mycas.table;
call execute ('%test(' || text || ')');
run;
When attempting to use call execute
on a CAS table, I encounter the following error:
ERROR: The subroutine EXECUTE is unknown, or cannot be accessed. Check your spelling. Either it was not found in the path(s) of
executable images, or there was incorrect or missing subroutine descriptor information.
ERROR: The action stopped due to errors.
Interestingly, when the sessref=mysess
option is removed from the data
statement, the code executes without errors:
data mycas.test;
set mycas.table;
call execute ('%test(' || text || ')');
run;
It seems that there might be an issue related to the sessref
option when using call execute
with CAS tables. as the %test
macro is defined properly and is accessible when sessref
option is not in use.This option is being used to ensure that all processing is done in CAS to prevent unwanted data transfer.
I would appreciate any guidance or suggestions on how to resolve this issue. thank you in advance!
The explicit usage of sessref enforces that the data step executes in CAS.
CAS doesn't support all functions and it also can't directly interact with the macro processor.
Restrictions and Notable Behaviors for DATA Step Processing, SAS CALL Routines and Functions That Are Not Supported in CAS
If the data step can't execute in CAS then it will execute in Compute. But if you use sessref then you instruct SAS not to do so.
Your code will run if you remove the sessref portion from your data step
This means of course that SAS will transfer the source data from CAS to Compute, execute single threaded under Compute and then write back the result to CAS - with all the impact this has on resource consumption and performance.
Have also a read of Controlling DATA Step Processing
....unless of course you use an option like sessref that instructs the data step to run in CAS (and only in CAS).
Maxim 1: Read the Documentation.
Quote from CALL EXECUTE Routine :
This function is not supported in a DATA step that runs in CAS.
Oh, I see now.
Guess I'll have to find an alternative approach. One of the uses CAS tables.
Thanks for pointing that out.
The explicit usage of sessref enforces that the data step executes in CAS.
CAS doesn't support all functions and it also can't directly interact with the macro processor.
Restrictions and Notable Behaviors for DATA Step Processing, SAS CALL Routines and Functions That Are Not Supported in CAS
If the data step can't execute in CAS then it will execute in Compute. But if you use sessref then you instruct SAS not to do so.
Your code will run if you remove the sessref portion from your data step
This means of course that SAS will transfer the source data from CAS to Compute, execute single threaded under Compute and then write back the result to CAS - with all the impact this has on resource consumption and performance.
Have also a read of Controlling DATA Step Processing
....unless of course you use an option like sessref that instructs the data step to run in CAS (and only in CAS).
Why is it important to execute this data step in CAS?
CALL EXECUTE is a code generator and usually doesn't (couldn't) benfit from parallel processing.
But there shoudn't be anything stopping you from creating/executing CAS compatible code from a CALL EXCUTE in SAS Compute data step.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.