SCOREACCEL Procedure

Example 9: Publish a Model to ADLS and Run in Azure Synapse

Features:

CASLIB statement

CAS procedure

PROC SCOREACCEL statement

PUBLISHMODEL statement

RUNMODEL statement

DELETEMODEL statement

Details

Note: Starting with 2026.04 for Azure Synapse, PROC SCOREACCEL is deprecated. The Model Publishing and Scoring action set and the SAS Embedded Process for Spark action set are also deprecated. The change is a result of a Microsoft announcement to end support for Azure Synapse Runtime for Apache Spark 3.4. You can no longer deploy the sepcorespark RPM in Synapse. You are encouraged to use PROC ACCELERATOR instead. To use PROC ACCELERATOR, you must deploy the SAS Embedded Process from the accelserver RPM. See Deployment Details for Databricks and Synapse.

In this example, PROC SCOREACCEL publishes a model to Microsoft Azure Data Lake Storage Gen2 (ADLS). Then PROC SCOREACCEL runs the model in Azure Synapse by using the SAS Embedded Process for Spark. The model runs against an SQL Server table.

For Synapse, PROC SCOREACCEL uses Azure Active Directory (Azure AD) application registration and role-based access control (RBAC). For essential information, such as how to specify the Synapse Spark pool Livy REST URL, and the requirements for SQL Server, see In-Database Model Scoring.

Program

cas mysess sessopts=(azuretenantid="tenant-id");

caslib myadls datasource=(
       srctype="adls"
       accountname="myaccount",
       applicationid="application-id",
       filesystem="mystorage",
       dnssuffix="dfs.core.windows.net"
       );
proc scoreaccel sessref=mysess;
   publishmodel
      exttype=filesystem
      caslib="myadls"
      password="RBAC-client-secret"
      modelname="mymodel"
      modeldir="/scoring/models"
      programfile="/myfiles/myprogram.ds2";
run; 
quit;
caslib myspark datasource=(
       srctype="spark",
       platform="synapse",
       username="application-id",
       password="RBAC-client-secret",
       schema="SQL-server-database-name",
       hadoopjarpath="path-to-hadoop-jar-files",
       jobmanagementurl="Livy-rest-url"
       );

proc cas;
   sparkEmbeddedProcess.startSparkEP caslib="myspark" 
      executorInstances=2 executorCores=2 
      executorMemory=10 driverMemory=4;
run; 
quit;
proc scoreaccel sessref=mysess;
   runmodel
      exttype=spark
      caslib="myspark"
      modelname="mymodel"
      modeldir="/scoring/models"
      intable="SQL-server-database-schema-name.in-table-name"
      outtable="SQL-server-database-schema-name.out-table-name";
run; 
quit;
proc scoreaccel sessref=mysess;
   deletemodel 
      exttype=filesystem
      caslib="myadls"
      password="RBAC-client-secret"
      modelname="mymodel"
      modeldir="/scoring/models";
run;
quit;

proc cas;
   sparkEmbeddedProcess.stopSparkEP caslib="myspark";
run; 
quit;

Program Description

Prepare to publish the model to Microsoft Azure Data Lake Storage Gen2 (ADLS). Start a CAS session. You must include the azuretenantid= session option.
cas mysess sessopts=(azuretenantid="tenant-id");
Assign a caslib to ADLS.
caslib myadls datasource=(
       srctype="adls"
       accountname="myaccount",
       applicationid="application-id",
       filesystem="mystorage",
       dnssuffix="dfs.core.windows.net"
       );
Publish the model to ADLS by specifying EXTTYPE=FILESYSTEM in the PUBLISHMODEL statement. In the CASLIB= argument, specify the ADLS caslib. For the PASSWORD= argument, use the password from RBAC, which is also known as the secret.
proc scoreaccel sessref=mysess;
   publishmodel
      exttype=filesystem
      caslib="myadls"
      password="RBAC-client-secret"
      modelname="mymodel"
      modeldir="/scoring/models"
      programfile="/myfiles/myprogram.ds2";
run; 
quit;
To run a model in Synapse, a Spark caslib is required. The username= is the application ID. For the password= parameter, use the password from RBAC, which is also known as the secret. For SQL Server tables, the schema name is the database name. For the jobmanagementurl= parameter, specify the Synapse Spark pool Livy REST URL. For more information about the jobManagementUrl= value, see Forming the Livy REST URL for Synapse. The Hadoop JAR path is required. The Hadoop configuration path is not required.
caslib myspark datasource=(
       srctype="spark",
       platform="synapse",
       username="application-id",
       password="RBAC-client-secret",
       schema="SQL-server-database-name",
       hadoopjarpath="path-to-hadoop-jar-files",
       jobmanagementurl="Livy-rest-url"
       );
Start the SAS Embedded Process for Spark continuous session. Use the CAS procedure to submit the startSparkEP action. In the caslib= parameter, specify the Spark caslib.
proc cas;
   sparkEmbeddedProcess.startSparkEP caslib="myspark" 
      executorInstances=2 executorCores=2 
      executorMemory=10 driverMemory=4;
run; 
quit;
Run the model in Synapse by specifying EXTTYPE=SPARK in the RUNMODEL statement. In the CASLIB= argument, specify the Spark caslib.
proc scoreaccel sessref=mysess;
   runmodel
      exttype=spark
      caslib="myspark"
      modelname="mymodel"
      modeldir="/scoring/models"
      intable="SQL-server-database-schema-name.in-table-name"
      outtable="SQL-server-database-schema-name.out-table-name";
run; 
quit;
Delete the model if needed.
proc scoreaccel sessref=mysess;
   deletemodel 
      exttype=filesystem
      caslib="myadls"
      password="RBAC-client-secret"
      modelname="mymodel"
      modeldir="/scoring/models";
run;
quit;
To stop the SAS Embedded Process for Spark continuous session, submit the stopSparkEP action. The session is also terminated when the CAS session is terminated.
proc cas;
   sparkEmbeddedProcess.stopSparkEP caslib="myspark";
run; 
quit;
Last updated: September 4, 2026