BookmarkSubscribeRSS Feed

How to Deploy SAS Decisions from Git to MAS

Started ‎03-14-2022 by
Modified ‎03-14-2022 by
Views 2,686

You can use the decisiongitdeploy SAS Viya Command Line Interface plug-in to deploy decisions or rule sets from a Git repository to SAS Viya. The decisions can include SAS models in their composition. You can deploy the decisions as SAS Micro Analytic Service (MAS) modules in any number of SAS Viya environments. When you deploy SAS decisions to MAS, your decision can be scored through a REST API. You can call the REST API from any application, programming language or script.


Publish to Git - Deploy from Git


The deployment process, which is the focus of this post, is highlighted by the orange block in the diagram.



Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.


Publish to Git


A series of posts have already discussed the publishing from SAS Viya to a Git repository:



Deploy from Git


The deployment process:

  • Make accessible the Git files containing the published decisions to the SAS Viya Command Line Interface (CLI).
  • Select the publishing destination.
  • Use the decisiongitdeploy SAS Viya CLI to deploy these decisions, to the SAS Viya publishing destination.


The decisiongitdeploy SAS Viya CLI


In SAS Viya, a command-line interface (CLI) is a user interface to the SAS Viya REST services. In this interface, you enter commands on a command line and receive a response back from the system. With the decisiongitdeploy CLI you can deploy decisions and rule sets from a local Git repository to a SAS Micro Analytic Service (MAS) environment or to a SAS Cloud Analytic Services (CAS) environment. You must publish the decisions and rule sets to a Git publishing destination, then, copy them into your local Git repository before you use the CLI. The decisiongitdeploy CLI, was first released in the SAS Viya 2021.2 (November 2021) long term support.


Make Accessible the Git Files to the SAS Viya CLI


To access the files from your Git repository, an easy option is to clone the Git repository. If you decide to clone a private GitHub repository with SAS Studio:


  • Create a Git profile.
  • HTTPS can be used as an authentication method.
  • The GitHub Personal Access Token acts as a password.
  • Choose a folder for the cloned repository. The example in the video uses a folder called gitDeploy.



Select the Publishing Destination


A Micro Analytic Service must exist prior to publishing. In most SAS Viya deployments, a MAS destination is created by default.


Use the decisiongitdeploy SAS Viya CLI


To deploy the decisions from the cloned files, you must use the SAS Viya Command Line Interface (CLI). The base assumption is that you have already installed the SAS Viya CLI.


Create a SAS Viya CLI Profile


First, you need to create a SAS Viya CLI profile. In our environment, the required script would look like:


# Get namespace and host
kubectl get ns
# Key variables – SAS Viya on RACE
# The SAS Viya Ingress URL in this example points to
INGRESS_SUFFIX=$(hostname -f)

# Get certificates (TLS support)
export SSL_CERT_FILE=~/.certs/${current_namespace}_trustedcerts.pem

# Confirm the sas-viya CLI folder
cd $clidir

# Create a SAS Viya CLI profile
export SAS_CLI_PROFILE=${current_namespace}
./sas-viya --profile ${SAS_CLI_PROFILE} profile set-endpoint "${INGRESS_URL}"
./sas-viya --profile ${SAS_CLI_PROFILE} profile toggle-color off
./sas-viya --profile ${SAS_CLI_PROFILE} profile set-output fulljson
./sas-viya --profile ${SAS_CLI_PROFILE} profile show


SAS Viya CLI Login


Second, you need to login with your SAS credentials. This will allow you to get a SAS Viya access token and perform the operations required. My recommendation is to use the pyviyatools for authentication.


tee ~/.authinfo > /dev/null << EOF
default user sasadm password ******

chmod 600 ~/.authinfo

# Login and create a token
cd ~/admin/pyviyatools
./ -f ~/.authinfo


The less elegant option is to directly employ the user and the password.


# Login and create a token
./sas-viya --profile ${SAS_CLI_PROFILE} auth login -user sasadm -password ******


Deploy to MAS


You must use the decisiongitdeploy plug-in to deploy the decision.


When you call the deploy command, you must be in the folder containing the decision files. This folder is where the Git repository was cloned locally.


In the example below, the gitDeploy folder contains two subfolders, one for each published rule set: autoAuction1_0 and autoAuctionMake1_0. The subfolder name is passed in the decisiongitdeploy command.



The deployment code looks like:


# Deploy from GIT to MAS

# cd to the folder where the repository containing published was cloned
cd /shared/gelcontent/home/sasadm/gitDeploy

# Confirm the folder where sas-viya CLI is installed
ls /opt/sas/viya/home/bin/

# Deploy a decision from Git
/opt/sas/viya/home/bin/sas-viya --profile ${SAS_CLI_PROFILE} decisiongitdeploy deploy --force true --destinationtype=MAS autoAuction1_0

# Deploy another decision from Git
/opt/sas/viya/home/bin/sas-viya --profile ${SAS_CLI_PROFILE} decisiongitdeploy deploy --force true --destinationtype=MAS autoAuctionMake1_0

# Notes
## --destinationtype=MAS parameter is optional, as MAS is the default deployment destination
## --force true, allows to overwrite a MAS module if it already exists; results in an error if the module exists and the parameter is not specified




To deploy rule sets or decisions, from a Git repository, to a SAS Viya Micro Analytic Service (MAS) publishing destination:

  • First, make the Git files accessible to the SAS Viya Command Line Interface (CLI).
  • Second, select the existing publishing destination.
  • Third, use the SAS Viya CLI decisiongitdeploy plug-in, to deploy to the chosen publishing destination.



Thank you for your time reading this post. If you liked the post, give it a thumbs up! Please comment and tell us what you think about the post content. If you wish to get more information, please write me an email.


Find more articles from SAS Global Enablement and Learning here.

Version history
Last update:
‎03-14-2022 08:09 PM
Updated by:



SAS is headed back to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team.

Interested in speaking? Content from our attendees is one of the reasons that makes SAS Innovate such a special event!

Submit your idea!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started