You can download code to run a SAS Visual Forecasting project in batch mode. The batch code runs all of the pipelines and exports the output of the champion pipeline to the caslib and table name that you specify. The dependent and time variables must be assigned before running the batch code. If the project is shared, only users with Read-Write access can run the batch code.
If the project includes Interactive Modeling, check the log for messages that might indicate whether models that were designated as champion have failed. If this happens, the time seriesan aggregation of transactional data into specified time intervals and sorted according to unique combinations of the default attributes (BY variables) is missing a champion model. You need to reassign champion models for these time series.
Follow these steps to download the batch code.
The Batch API window is displayed with the code for the project inline.
You need to provide these values in the downloaded code.
hosthost name of the SAS Model Studio server
usernameunique user name or ID of the user running the batch code
passwordpassword that belongs to
username
outputCaslibthe name of an existing caslib where you want to store the OUTFOR table for the project.
outputTablethe name of the table for the project output.
The following shows where to provide this information for the batch file.
SASLook for the following lines of code at the end
of the batch file. The host,
username, and
projectId should already be provided. Update the
password,
outputCaslib, and
outputTable variables as shown:
%let host = test.example.com;
%let username = my_username;
%let password = my_password;
%let projectId = a0548b2f-a669-4a10-a4dd-052c671c0c00;
/* Set the following to export the output data */
%let outputCaslib = myCas;
%let outputTable = OutputForecasts;
PythonSet these parameters on the command line. For example, if download.py is the file name of the Python batch code, invoke the command:
$ python download.py –-host test.example.com –-username my_username
-–password my_password –-outputCaslib myCas –-outputTab OutputForecasts
If you have overrides in the project, they might
generate conflicts when they are submitted by the batch code. You can update the batch
code to
automatically resolve these conflicts by adding autoresolve="true" to
the code.
SASFind the PROC HTTP procedure that includes the
following IN option with firstTransaction and
lastTransaction.
in="{""firstTransaction"":""@first"",""lastTransaction"":""@last""}"
Add the autoResolve setting, as follows:
in="{""firstTransaction"":""@first"",""lastTransaction"":""@last"",
""autoResolve"":true}"
PythonFind the resubmit_overrides function:
def resubmit_overrides(env):
Update the body statement with autoResolve assignment.
body = '{\"firstTransaction\":\"@first\",\"lastTransaction\":\"@last\",
\"autoResolve\":true}'
Editing the Batch Code shows how to authenticate by providing your user credentials as macro variables in the batch code. Here are two other options for authenticating when running batch.
When running the batch code via SAS Studio, a token is automatically created for the user. It can be used by modifying each PROC HTTP call to include this statement:
oauth_bearer=SAS_SERVICES;
If you choose this option, the first PROC HTTP call needs to be removed from the downloaded SAS code. (The first PROC HTTP call is used to get a token through the user name and password.) It should look similar to this:
proc http
method="POST"
url="https://&host./SASLogon/oauth/token"
in="grant_type=password%nrstr(&)username=&username.%nrstr(&)password=&password."
out=resp;
headers
"Authorization"="Basic c2FzLmVjOg=="
"Accept"="application/json"
"Content-Type"="application/x-www-form-urlencoded";
run;
Follow the steps in Authentication to SAS Viya: a couple of approaches to register a client. Then you need to modify the batch code to request a token using the client instead of user name and password.