Recently in the SAS Community Library: Creating snappy and eye-catching email headers for marketing campaigns can often be difficult. SAS' @ADAMPOLLACCHI introduces you to a new feature available in SAS Customer Intelligence 360: Gen AI email headers.
Hi All!
A colleague and I are investigating the use of SAS Viya's API's to call a model (we are both SAS programmers and have very little experience with API's), I feel like we have made some good progress but seem to be falling at the last hurdle, submitting data to the model.
we have a dataset which we want to submit to the model and are using proc json to convert it and then proc http to submit it, ensuring only the variables that model is expecting exist on the final dataset by using the modules endpoint but whatever we do we seem to end up with a "415 Unsupported Media Type" error... if someone can help us out it would be massively appreciated:
/* Setup steps */
*/ Obtain URL for the environment;
%let myviyaurl=%sysfunc(getoption(servicesbaseurl));
/* define global macros */
%global status;
%global myurl;
/* define files used */
filename resp temp; /*temporary response handler*/
filename hdrin temp; /*temporary header handler for sending*/
filename headers temp;/*temporary header handler for recieving*/
/* define macros */
/*macro for building URL's to use in API calls*/
%macro buildURI(suffix);
data _null_;
url=cats("'", "&myviyaurl", "&suffix.","'");
call symputx('myurl', url, 'G');
run;
%mend buildURI;
/*Macro to make API calls*/
%macro make_API_call(type=GET,Headers=);
proc http
method="&type."
url=%unquote(%superq(myURL)) out=resp
OAUTH_BEARER=SAS_SERVICES VERBOSE;
%if &Headers ne %then %do;
headers
&headers.
;
%end;
run;
%mend make_API_call;
/*MAIN PROCESS FLOWS*/
*/ Build URL for the REST API call with correct endpoint;
%buildURI(/microanalyticScore/modules);
*/Run REST API call to get list of discorvery agents using PROC HTTP;
%make_API_call(type=GET);
*/ Define a JSON library to read the API response;
libname resp json;
/* get the ordinal link for the smote model from items */
proc sql noprint;
select ordinal_items into:ordinal
from resp.Items
where id = "smote champion model";
quit;
/*GET the endpoint to point to steps for next API call*/
proc sql noprint;
select URI into:suffix
from resp.Items_links
where rel = "steps" and ordinal_items = &ordinal.;
quit;
filename resp clear; /*clear response temp file*/
libname resp clear; /*clear response temp libname*/
filename resp temp; /*temporary response handler*/
*/ Build URL for the REST API call with correct endpoint;
%buildURI(&suffix.);
*/Run REST API call to get list of discorvery agents using PROC HTTP;
%make_API_call(type=GET);
*/ Define a JSON library to read the API response;
libname resp json;
/*get a list of variables that the model is expecting*/
proc sql noprint;
select name
into :var_list separated by ' '
from RESP.ITEMS_INPUTS
;quit;
/*TESTING*/
/*TESTING*/
/*TESTING*/
cas; caslib _ALL_ assign;
filename myjson clear; /*clear temporary files*/
filename resp3 clear;
libname myjson clear;/*clear temporary files*/
/*create a temporary Json file that will be used to send data to MAS*/
filename myjson "/ald/Workspace/Stewart.Jardine/Temp_JSON/smote.json"; /* Define the output JSON file */
proc json out=myjson pretty keys;
export public.SMOTE_SOURCE_DATA(keep= &var_list.)/ keys; /* Convert the dataset */
run;
filename resp3 temp;
%let Link= https://aldermore.ondemand.sas.com/microanalyticScore/modules/smote%20champion%20model/steps/score;
proc http
url= "&Link."
method="POST"
oauth_bearer=SAS_SERVICES VERBOSE
in=myjson
out=resp3;
run;
... View more
I am trying to configure a client to run jobs in Viya 4. I followed the steps in this blog: https://blogs.sas.com/content/sgf/2023/02/07/authentication-to-sas-viya/ Here is the relevant configuration of my client: {
"scope": ["uaa.none"],
"client_id": "newclient",
"authorized_grant_types": ["client_credentials"],
"authorities": ["SASAdministrators"],
} I successfully obtain an access token using this client. However, when I use the token to submit a job request: import requests
url = "http://example.com/jobExecution/jobRequests/{jobRequestId}/jobs"
payload = ""
headers = {
"Delegate-Domain": "<MyAuthTokenDomain>",
"Content-Type": "application/json",
"Authorization": "Bearer <ACCESS-TOKEN>",
"Accept": "application/json"
}
response = requests.post(url, data=payload, headers=headers) I get the following error: {
"errorCode": 0,
"message": "OAuth2 user authentication is required for Delegate-Domain header",
"details": ["path: /jobExecution/jobRequests/{jobid}/jobs"],
"links": [],
"version": 2,
"httpStatusCode": 401
} However, if I remove the Delegate-Domain header, the request succeeds (HTTP 201), but the job in Environment Manager -> Jobs and Flows fails with: "invalid user: 'newclient'" (error code 30081) Related to Credentials Microservice? I came across this blog, which explains how the Credentials Microservice determines identity types and manages credentials. It mentions that: Custom applications should be registered as part of a group so that credentials can be managed for them. The default authentication domain ( DefaultAuth ) is used unless configured otherwise ( sas.compute.domain.default ). In my case: The sas.compute.domain.defaultis currently set to DefaultAuth, but no users have credentials associated with it. Instead, a Token Authentication Domain has been created, which is managed by a service account. This Token Authentication Domain is what the client includes in the Delegate-Domain header when submitting a job request. The service account has granted the Token Authentication Domain credentials to the SASAdministrators group, which my client (newclient) is a member of. Questions: Should the request to submit the job include the Delegate-Domain header when using the client_credentials grant? If so, how can I avoid the error:"OAuth2 user authentication is required for Delegate-Domain header" Would changing sas.compute.domain.defaultis to the Token Authentication Domain allow my client to make use of the Token Authentication Domain in order to submit jobs successfully? If I make this change, would it grant excessive permissions to all users in the application? Is there a more secure way to configure this? Is there a better way to associate my client with valid credentials so it can submit jobs correctly?
... View more
Hi guys,
suppose to have the following table:
data DB;
input ID :$20. Admission :date09. Discharge :date09. Age_class Age_end Index Value Total;
format Admission date9. Discharge date9.;
cards;
0001 01JUL2014 16AUG2014 1 4 1 2.3 11.9
0001 13MAY2018 22JUN2018 3 4 0 1.4 .
0001 23JAN2019 25JAN2019 4 4 0 3.2 .
0002 13MAY2016 22SEP2016 1 5 1 2 7.9
0002 09JUL2023 10JUL2023 2 5 0 0.3 .
0002 12SEP2024 15SEP2024 3 5 0 0.2 .
0003 01JUL2014 18AUG2014 1 3 1 12 17.3
0003 07DEC2023 16DEC2023 2 3 0 0.3 .
0004 12JAN2014 15JAN2014 1 2 1 2 2.1
0004 30MAY2019 13JUL2019 2 2 0 0.1 .
0005 30JUN2019 13OCT2019 5 5 0 4.1 .
;
run;
Is there a way to get the following?
data DB1;
input ID :$20. Admission :date09. Discharge :date09. Age_class Age_end Index Value Total Age_class1 Age_class2 Age_class3 Age_class4 Age_class5;
format Admission date9. Discharge date9.;
cards;
0001 01JUL2014 16AUG2014 1 4 1 2.3 11.9 2.3 1.4 5 3.2 .
0001 13MAY2018 22JUN2018 3 4 0 1.4 . . . . . .
0001 23JAN2019 25JAN2019 4 4 0 3.2 . . . . . .
0002 13MAY2016 22SEP2016 1 5 1 2 7.9 2 0.3 0.2 5 0.4
0002 09JUL2023 10JUL2023 2 5 0 0.3 . . . . . .
0002 12SEP2024 15SEP2024 3 5 0 0.2 . . . . . .
0003 01JUL2014 18AUG2014 1 3 1 12 17.3 12 0.3 5 . .
0003 07DEC2023 16DEC2023 2 3 0 0.3 . . . . . .
0004 12JAN2014 15JAN2014 1 2 1 2 2.1 2 0.1 . . .
0004 30MAY2019 13JUL2019 2 2 0 0.1 . . . . . .
0005 30JUN2019 13OCT2019 5 5 0 4.1 4.1 . . . . 4.1
;
run;
In other words, for each ID in DB there is the Age_class at each admission and an Age_class at exit (Age_end) from the study. Then, there is the "Value" variable that is the time the patient stay in the corresponding Age_class (before exit). There is also a "Total" time in the study. What I need is to transform the dataset DB into a wide format where there are columns corresponding to the age classes filled by the corresponding Value. Note that in this new dataset the row-wise total must be reached and must be equal to "Total" and so: if there is a jump in the age classes (Age_class variable) a value = 5 years must be added because the age-class interval is of max 5 years.
Finally, in the new wide dataset (DB1) rows must be filled only where Index = 1
Can anyone help me please?
Thank you very much in advance
... View more
The SAS Dynamic Actuarial Modeling Premier solution offers a comprehensive renewal optimization workflow specifically designed to streamline and enhance the process of optimizing price increases for premium renewals.The article introduces the renewal optimization workflow and provides examples of the setting up objectives and constraints using SAS Model Studio in SAS Dynamic Actuarial Modelling for your optimization needs. This article shall motivate actuaries and modelers to try out and test several configuration options based on your requirements.
... View more
Hello,
I have a file hosted on unix server who name is Virage Survey.xml
I would like to change the name for VirageSurvey.xml
I have tried this unix command directly on the terminal and it works
mv "path1/Virage Survey.xml" "path1/VirageSurvey.xml"
but in SAS EG I have tried this and nothing append.
x 'mv "path1/Virage Survey.xml" "path1/VirageSurvey.xml"';
Any suggestion
... View more
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Nominations are in, and the SAS Customer Recognition Awards are open for your votes! Winners get a full trip to SAS Innovate (May 6-9) in Orlando, FL! See the 60+ inspiring entries from SAS users!