BookmarkSubscribeRSS Feed

Intelligent Decisioning: Update a Global Variable via REST

Started ‎09-30-2021 by
Modified ‎09-30-2021 by
Views 4,006

Global variables have existed in Intelligent Decisioning since the 5.5 release. Lookup tables have existed from the beginning. I mention lookup tables and global variables together because they are more or less the same thing. Both are implemented as hash objects in MAS and formats (or in-line conditional logic code) in CAS. For the most part, a global variable is just a one row lookup table.




Global Variable Example



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


So, naturally people's first reaction to seeing global variables is the same as their first reaction to seeing lookup tables. They want to update them programmatically, without using the SID user interface. So let's do that here with REST...


Find the global variable URI

First, we'll need to locate our global variable's universal resource identifier. We could do this programmatically but we'll just look it up in the Viya UI to get a little context. As, the image below shows, you can find the URI by editing the global variable and looking on the versions tab. Note that, for this exercise, we want the global variable URI, not the version ("revision") URI.


When we update a global variable, the "Displayed Version" will be updated.



GET the Global Variable ETag

Next, we need to perform a GET request on the global variable to obtain its current ETag. We need the ETag when we perform the update in the next step. REST uses the ETag to help avoid update collisions.


Note that we use the global variable URI, /referenceData/globalVariables/2744cc6d-53bf-490a-8dc7-352dead40ace, in the GET request:


GET /referenceData/globalVariables/2744cc6d-53bf-490a-8dc7-352dead40ace/ HTTP/1.1
Accept: application/json
Content-Type: application/json;charset=utf-8
Cookie: sas-ingress-nginx=6e50bb65648b4904ca91085f11bee901


The ETag is returned in the response header, shown below in Postman.





Update (PUT) the Global Variable

With both the URI and the ETag, we can now update the global variable. The HTTP request is below. Note the following:


  • The request uses an HTTP PUT.
  • The ETag is used in the If-Match request header element.
  • The request body only requires a few fields from the full global variable schema.
  • The request body changes the global variable value from 1.19 (shown above) to 1.2.
PUT /referenceData/globalVariables/2744cc6d-53bf-490a-8dc7-352dead40ace/ HTTP/1.1
Accept: application/json
Content-Type: application/json;charset=utf-8
If-Match: "ktorw3bn"
Cookie: sas-ingress-nginx=6ff3a6db3117ea6c83b58f72ff5d473a
Content-Length: 104

  "name": "eurusa",
  "description": "eurusa",
  "defaultValue": 1.2,
  "dataType": "decimal"


And we then we can see that value changed in the user interface….




Next Steps


  • Want to update/add/delete global variables, lookup tables and, more without using the UI? Check out the Viya REST API at .
  • So now that we've updated the global variable, we'll, of course, have to re-activate it. You can see the API doc for that here and we'll cover it in a future post as well. .
  • Of course, we'll want to script this whole process so that we can easily run it when we want. We can do that in SAS with PROC HTTP as well as a host of other languages including Python.
Version history
Last update:
‎09-30-2021 04:12 PM
Updated by:



Registration is open! SAS is returning 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. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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

Article Labels
Article Tags