As this might be helpful for someone, I'd like to share a one possible solution using PROC HTTP for API call to get library definition and assign a library It is important to get and use predescribed library definitions when you have thousands of jobs and suddenly you have to move your storage %let lib_ref = SASHELP; /* as example */
%let SERVICESBASEURL=%sysfunc(getoption(servicesbaseurl));
/* Assign a temporary file to store the response */
filename resp temp;
proc http
url="&SERVICESBASEURL./dataSources/providers/Compute/sourceDefinitions?filter=eq(defaultLibref,%27&lib_ref.%27)"
method="GET"
oauth_bearer=sas_services
out=resp;
headers
"Accept"="application/json";
run;
libname respjson json fileref=resp;
/* Check if the dataset exists */
%if %sysfunc(exist(respjson.items_links)) %then %do;
/* assign library definition value to macro variable*/
data _null_;
set respjson.items_links;
where ordinal_items = 1 and rel = 'self'; /* choose the first match */
call symputx('lib_def', uri);
run;
%end;
%else %do;
%put --------------------;
%put WARNING: Library &lib_ref. was not found.;
%put --------------------;
%return;
%end;
libname respjson clear;
libname &lib_ref. libdef="&lib_def.";
... View more