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...
.
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.
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
Host: yourViyaHost.comp.com:443
Accept: application/json
Content-Type: application/json;charset=utf-8
Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXX
Cookie: sas-ingress-nginx=6e50bb65648b4904ca91085f11bee901
The ETag is returned in the response header, shown below in Postman.
With both the URI and the ETag, we can now update the global variable. The HTTP request is below. Note the following:
PUT /referenceData/globalVariables/2744cc6d-53bf-490a-8dc7-352dead40ace/ HTTP/1.1
Host: yourViyaHost.comp.com:443
Accept: application/json
Content-Type: application/json;charset=utf-8
If-Match: "ktorw3bn"
Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
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….
.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.