mirror of
https://github.com/sasjs/core.git
synced 2025-12-19 09:34:34 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
459beff4fa | ||
|
|
1c873afe57 | ||
|
|
2b683509ac | ||
|
|
dcccd1491d | ||
|
|
8d9b84037c |
51
all.sas
51
all.sas
@@ -510,6 +510,7 @@ options noquotelenmax;
|
|||||||
|
|
||||||
<h4> Dependencies </h4>
|
<h4> Dependencies </h4>
|
||||||
@li mf_mval.sas
|
@li mf_mval.sas
|
||||||
|
@li mf_trimstr.sas
|
||||||
|
|
||||||
@version 9.4 / 3.4
|
@version 9.4 / 3.4
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
@@ -555,7 +556,7 @@ options noquotelenmax;
|
|||||||
%else 0;
|
%else 0;
|
||||||
%end;
|
%end;
|
||||||
%else %if &switch=VIYARESTAPI %then %do;
|
%else %if &switch=VIYARESTAPI %then %do;
|
||||||
%sysfunc(getoption(servicesbaseurl))
|
%mf_trimstr(%sysfunc(getoption(servicesbaseurl)),/)
|
||||||
%end;
|
%end;
|
||||||
%mend;/**
|
%mend;/**
|
||||||
@file
|
@file
|
||||||
@@ -1290,6 +1291,44 @@ Usage:
|
|||||||
%macro mf_nobs(libds
|
%macro mf_nobs(libds
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
%mf_getattrn(&libds,NLOBS)
|
%mf_getattrn(&libds,NLOBS)
|
||||||
|
%mend;/**
|
||||||
|
@file mf_trimstr.sas
|
||||||
|
@brief Removes character(s) from the end, if they exist
|
||||||
|
@details If the designated characters exist at the end of the string, they
|
||||||
|
are removed
|
||||||
|
|
||||||
|
%put %mf_trimstr(/blah/,/); * /blah;
|
||||||
|
%put %mf_trimstr(/blah/,h); * /blah/;
|
||||||
|
%put %mf_trimstr(/blah/,h/); */bla;
|
||||||
|
|
||||||
|
<h4> Dependencies </h4>
|
||||||
|
|
||||||
|
|
||||||
|
@param basestr The string to be modified
|
||||||
|
@param trimstr The string to be removed from the end of `basestr`, if it exists
|
||||||
|
|
||||||
|
@return output returns result with the value of `trimstr` removed from the end
|
||||||
|
|
||||||
|
|
||||||
|
@version 9.2
|
||||||
|
@author Allan Bowe
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mf_trimstr(basestr,trimstr);
|
||||||
|
%local trimlen trimval;
|
||||||
|
%let trimlen=%length(%superq(trimstr));
|
||||||
|
%let trimval=%qsubstr(%superq(basestr)
|
||||||
|
,%length(%superq(basestr))-&trimlen+1
|
||||||
|
,&trimlen);
|
||||||
|
|
||||||
|
%if %superq(trimval)=%superq(trimstr) %then %do;
|
||||||
|
%qsubstr(%superq(basestr),1,%length(%superq(basestr))-&trimlen)
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
&basestr
|
||||||
|
%end;
|
||||||
|
|
||||||
%mend;/**
|
%mend;/**
|
||||||
@file
|
@file
|
||||||
@brief Creates a Unique ID based on system time in a friendly format
|
@brief Creates a Unique ID based on system time in a friendly format
|
||||||
@@ -9744,7 +9783,7 @@ options noquotelenmax;
|
|||||||
data _null_;
|
data _null_;
|
||||||
set &libref1..links;
|
set &libref1..links;
|
||||||
if rel='createChild' then
|
if rel='createChild' then
|
||||||
call symputx('href',quote(trim(href)),'l');
|
call symputx('href',quote("&base_uri"!!trim(href)),'l');
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
%else %if &SYS_PROCHTTP_STATUS_CODE=404 %then %do;
|
%else %if &SYS_PROCHTTP_STATUS_CODE=404 %then %do;
|
||||||
@@ -9943,7 +9982,7 @@ libname &libref1 JSON fileref=&fname1;
|
|||||||
|
|
||||||
data _null_;
|
data _null_;
|
||||||
set &libref1..links;
|
set &libref1..links;
|
||||||
if rel='members' then call symputx('membercheck',quote(trim(href)),'l');
|
if rel='members' then call symputx('membercheck',quote("&base_uri"!!trim(href)),'l');
|
||||||
else if rel='self' then call symputx('parentFolderUri',href,'l');
|
else if rel='self' then call symputx('parentFolderUri',href,'l');
|
||||||
run;
|
run;
|
||||||
data _null_;
|
data _null_;
|
||||||
@@ -10409,7 +10448,7 @@ proc http method='POST'
|
|||||||
in=&fname3
|
in=&fname3
|
||||||
out=&fname4
|
out=&fname4
|
||||||
&oauth_bearer
|
&oauth_bearer
|
||||||
url="/jobDefinitions/definitions?parentFolderUri=&parentFolderUri";
|
url="&base_uri/jobDefinitions/definitions?parentFolderUri=&parentFolderUri";
|
||||||
headers 'Content-Type'='application/vnd.sas.job.definition+json'
|
headers 'Content-Type'='application/vnd.sas.job.definition+json'
|
||||||
%if &grant_type=authorization_code %then %do;
|
%if &grant_type=authorization_code %then %do;
|
||||||
"Authorization"="Bearer &&&access_token_var"
|
"Authorization"="Bearer &&&access_token_var"
|
||||||
@@ -10703,7 +10742,7 @@ run;
|
|||||||
libname &libref1 JSON fileref=&fname1;
|
libname &libref1 JSON fileref=&fname1;
|
||||||
data _null_;
|
data _null_;
|
||||||
set &libref1..links;
|
set &libref1..links;
|
||||||
if rel='members' then call symputx('mref',quote(trim(href)),'l');
|
if rel='members' then call symputx('mref',quote("&base_uri"!!trim(href)),'l');
|
||||||
run;
|
run;
|
||||||
|
|
||||||
/* get the children */
|
/* get the children */
|
||||||
@@ -10725,7 +10764,7 @@ libname &libref1a JSON fileref=&fname1a;
|
|||||||
data _null_;
|
data _null_;
|
||||||
set &libref1a..items;
|
set &libref1a..items;
|
||||||
if contenttype='jobDefinition' and upcase(name)="%upcase(&name)" then do;
|
if contenttype='jobDefinition' and upcase(name)="%upcase(&name)" then do;
|
||||||
call symputx('uri',uri,'l');
|
call symputx('uri',cats("&base_uri",uri),'l');
|
||||||
call symputx('found',1,'l');
|
call symputx('found',1,'l');
|
||||||
end;
|
end;
|
||||||
run;
|
run;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
<h4> Dependencies </h4>
|
<h4> Dependencies </h4>
|
||||||
@li mf_mval.sas
|
@li mf_mval.sas
|
||||||
|
@li mf_trimstr.sas
|
||||||
|
|
||||||
@version 9.4 / 3.4
|
@version 9.4 / 3.4
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
@@ -57,6 +58,6 @@
|
|||||||
%else 0;
|
%else 0;
|
||||||
%end;
|
%end;
|
||||||
%else %if &switch=VIYARESTAPI %then %do;
|
%else %if &switch=VIYARESTAPI %then %do;
|
||||||
%sysfunc(getoption(servicesbaseurl))
|
%mf_trimstr(%sysfunc(getoption(servicesbaseurl)),/)
|
||||||
%end;
|
%end;
|
||||||
%mend;
|
%mend;
|
||||||
39
base/mf_trimstr.sas
Normal file
39
base/mf_trimstr.sas
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
@file mf_trimstr.sas
|
||||||
|
@brief Removes character(s) from the end, if they exist
|
||||||
|
@details If the designated characters exist at the end of the string, they
|
||||||
|
are removed
|
||||||
|
|
||||||
|
%put %mf_trimstr(/blah/,/); * /blah;
|
||||||
|
%put %mf_trimstr(/blah/,h); * /blah/;
|
||||||
|
%put %mf_trimstr(/blah/,h/); */bla;
|
||||||
|
|
||||||
|
<h4> Dependencies </h4>
|
||||||
|
|
||||||
|
|
||||||
|
@param basestr The string to be modified
|
||||||
|
@param trimstr The string to be removed from the end of `basestr`, if it exists
|
||||||
|
|
||||||
|
@return output returns result with the value of `trimstr` removed from the end
|
||||||
|
|
||||||
|
|
||||||
|
@version 9.2
|
||||||
|
@author Allan Bowe
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mf_trimstr(basestr,trimstr);
|
||||||
|
%local trimlen trimval;
|
||||||
|
%let trimlen=%length(%superq(trimstr));
|
||||||
|
%let trimval=%qsubstr(%superq(basestr)
|
||||||
|
,%length(%superq(basestr))-&trimlen+1
|
||||||
|
,&trimlen);
|
||||||
|
|
||||||
|
%if %superq(trimval)=%superq(trimstr) %then %do;
|
||||||
|
%qsubstr(%superq(basestr),1,%length(%superq(basestr))-&trimlen)
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
&basestr
|
||||||
|
%end;
|
||||||
|
|
||||||
|
%mend;
|
||||||
@@ -96,7 +96,7 @@ options noquotelenmax;
|
|||||||
data _null_;
|
data _null_;
|
||||||
set &libref1..links;
|
set &libref1..links;
|
||||||
if rel='createChild' then
|
if rel='createChild' then
|
||||||
call symputx('href',quote(trim(href)),'l');
|
call symputx('href',quote("&base_uri"!!trim(href)),'l');
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
%else %if &SYS_PROCHTTP_STATUS_CODE=404 %then %do;
|
%else %if &SYS_PROCHTTP_STATUS_CODE=404 %then %do;
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ libname &libref1 JSON fileref=&fname1;
|
|||||||
|
|
||||||
data _null_;
|
data _null_;
|
||||||
set &libref1..links;
|
set &libref1..links;
|
||||||
if rel='members' then call symputx('membercheck',quote(trim(href)),'l');
|
if rel='members' then call symputx('membercheck',quote("&base_uri"!!trim(href)),'l');
|
||||||
else if rel='self' then call symputx('parentFolderUri',href,'l');
|
else if rel='self' then call symputx('parentFolderUri',href,'l');
|
||||||
run;
|
run;
|
||||||
data _null_;
|
data _null_;
|
||||||
@@ -609,7 +609,7 @@ proc http method='POST'
|
|||||||
in=&fname3
|
in=&fname3
|
||||||
out=&fname4
|
out=&fname4
|
||||||
&oauth_bearer
|
&oauth_bearer
|
||||||
url="/jobDefinitions/definitions?parentFolderUri=&parentFolderUri";
|
url="&base_uri/jobDefinitions/definitions?parentFolderUri=&parentFolderUri";
|
||||||
headers 'Content-Type'='application/vnd.sas.job.definition+json'
|
headers 'Content-Type'='application/vnd.sas.job.definition+json'
|
||||||
%if &grant_type=authorization_code %then %do;
|
%if &grant_type=authorization_code %then %do;
|
||||||
"Authorization"="Bearer &&&access_token_var"
|
"Authorization"="Bearer &&&access_token_var"
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ run;
|
|||||||
libname &libref1 JSON fileref=&fname1;
|
libname &libref1 JSON fileref=&fname1;
|
||||||
data _null_;
|
data _null_;
|
||||||
set &libref1..links;
|
set &libref1..links;
|
||||||
if rel='members' then call symputx('mref',quote(trim(href)),'l');
|
if rel='members' then call symputx('mref',quote("&base_uri"!!trim(href)),'l');
|
||||||
run;
|
run;
|
||||||
|
|
||||||
/* get the children */
|
/* get the children */
|
||||||
@@ -117,7 +117,7 @@ libname &libref1a JSON fileref=&fname1a;
|
|||||||
data _null_;
|
data _null_;
|
||||||
set &libref1a..items;
|
set &libref1a..items;
|
||||||
if contenttype='jobDefinition' and upcase(name)="%upcase(&name)" then do;
|
if contenttype='jobDefinition' and upcase(name)="%upcase(&name)" then do;
|
||||||
call symputx('uri',uri,'l');
|
call symputx('uri',cats("&base_uri",uri),'l');
|
||||||
call symputx('found',1,'l');
|
call symputx('found',1,'l');
|
||||||
end;
|
end;
|
||||||
run;
|
run;
|
||||||
|
|||||||
Reference in New Issue
Block a user