mirror of
https://github.com/sasjs/core.git
synced 2025-12-11 06:24:35 +00:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df832a184f | ||
|
|
15084be09d | ||
|
|
92ff1a53dc | ||
|
|
7dd219e9f1 | ||
|
|
cdd2b88b09 | ||
|
|
7e4fb4a640 | ||
|
|
a428b4f66c | ||
|
|
e2f0577e78 | ||
|
|
d53eff7771 | ||
|
|
5b56c85455 | ||
|
|
ff519c7f39 | ||
|
|
7d7778fd36 | ||
|
|
b47f31cfe6 | ||
|
|
542039b425 | ||
|
|
cc908a82bc | ||
|
|
71c31046f4 | ||
|
|
33a487b2b4 |
3
.github/FUNDING.yml
vendored
3
.github/FUNDING.yml
vendored
@@ -1,3 +0,0 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
custom: https://getalby.com/p/sasjs
|
||||
@@ -1,6 +0,0 @@
|
||||
FROM gitpod/workspace-full
|
||||
|
||||
RUN sudo apt-get update \
|
||||
&& sudo apt-get install -y doxygen \
|
||||
&& sudo apt-get install -y graphviz \
|
||||
&& sudo rm -rf /var/lib/apt/lists/*
|
||||
27
.gitpod.yml
27
.gitpod.yml
@@ -1,27 +0,0 @@
|
||||
tasks:
|
||||
- init: npm install -g npm
|
||||
- command: npm i
|
||||
- command: npm i -g @sasjs/cli
|
||||
|
||||
image:
|
||||
file: .gitpod.dockerfile
|
||||
vscode:
|
||||
extensions:
|
||||
- sasjs.sasjs-for-vscode
|
||||
|
||||
github:
|
||||
prebuilds:
|
||||
# enable for the master/default branch (defaults to true)
|
||||
master: true
|
||||
# enable for all branches in this repo (defaults to false)
|
||||
branches: false
|
||||
# enable for pull requests coming from this repo (defaults to true)
|
||||
pullRequests: true
|
||||
# enable for pull requests coming from forks (defaults to false)
|
||||
pullRequestsFromForks: true
|
||||
# add a "Review in Gitpod" button as a comment to pull requests (defaults to true)
|
||||
addComment: true
|
||||
# add a "Review in Gitpod" button to pull requests (defaults to false)
|
||||
addBadge: false
|
||||
# add a label once the prebuild is ready to pull requests (defaults to false)
|
||||
addLabel: prebuilt-in-gitpod
|
||||
13
README.md
13
README.md
@@ -1,19 +1,12 @@
|
||||
# Macro Core
|
||||
[![npm package][npm-image]][npm-url]
|
||||
[![Github Workflow][githubworkflow-image]][githubworkflow-url]
|
||||
|
||||
[](http://npmjs.org/package/@sasjs/core)
|
||||
[](https://github.com/sasjs/core/blob/main/.github/workflows/main.yml)
|
||||

|
||||

|
||||
[](https://github.com/sasjs/core/issues?q=is%3Aissue+is%3Aclosed)
|
||||
[](https://github.com/sasjs/core/issues)
|
||||

|
||||
[](https://gitpod.io/#https://github.com/sasjs/core)
|
||||
|
||||
|
||||
[npm-image]:https://img.shields.io/npm/v/@sasjs/core.svg
|
||||
[npm-url]:http://npmjs.org/package/@sasjs/core
|
||||
[githubworkflow-image]:https://github.com/sasjs/core/actions/workflows/main.yml/badge.svg
|
||||
[githubworkflow-url]:https://github.com/sasjs/core/blob/main/.github/workflows/main.yml
|
||||
[dependency-url]:https://github.com/sasjs/core/blob/main/package.json
|
||||
|
||||
|
||||
Much quality. Many standards. The **Macro Core** library exists to save time and development effort! Herein ye shall find a veritable host of MIT-licenced, production quality SAS macros. These are a mix of tools, utilities, functions and code generators that are useful in the context of [Application Development](https://sasapps.io) on the SAS platform (eg https://datacontroller.io). [Contributions](https://github.com/sasjs/core/blob/main/.github/CONTRIBUTING.md) are welcome.
|
||||
|
||||
59
all.sas
59
all.sas
@@ -11943,7 +11943,7 @@ data _null_;
|
||||
run;
|
||||
|
||||
/* END */
|
||||
%put &sysmacroname took %sysevalf(%sysfunc(datetime())-&dttm) seconds to run;
|
||||
/* %put &sysmacroname took %sysevalf(%sysfunc(datetime())-&dttm) secs to run; */
|
||||
|
||||
%mend mp_replace;
|
||||
/**
|
||||
@@ -24098,18 +24098,25 @@ run;
|
||||
msg=Cannot enter mfv_existfolder.sas with syscc=&syscc
|
||||
)
|
||||
|
||||
%local fref rc;
|
||||
%local fref rc var;
|
||||
%let fref=%mf_getuniquefileref();
|
||||
|
||||
%if %sysfunc(filename(fref,,filesrvc,folderPath="&path"))=0 %then %do;
|
||||
1
|
||||
%let var=_FILESRVC_&fref._URI;
|
||||
%let rc=%sysfunc(filename(fref));
|
||||
%symdel &var;
|
||||
%end;
|
||||
%else %do;
|
||||
0
|
||||
%let syscc=0;
|
||||
%end;
|
||||
|
||||
%mf_abort(
|
||||
iftrue=(&syscc ne 0),
|
||||
msg=Cannot leave mfv_existfolder.sas with syscc=&syscc
|
||||
)
|
||||
|
||||
%mend mfv_existfolder;/**
|
||||
@file mfv_existsashdat.sas
|
||||
@brief Checks whether a CAS sashdat dataset exists in persistent storage.
|
||||
@@ -24273,6 +24280,10 @@ run;
|
||||
%let syscc=0;
|
||||
%end;
|
||||
|
||||
%mf_abort(
|
||||
iftrue=(&syscc ne 0),
|
||||
msg=Cannot leave &sysmacroname with syscc=&syscc
|
||||
)
|
||||
%mend mfv_getpathuri;/**
|
||||
@file
|
||||
@brief Creates a file in SAS Drive using the API method
|
||||
@@ -24370,6 +24381,11 @@ run;
|
||||
%end;
|
||||
%else %let dbg=*;
|
||||
|
||||
%mp_abort(
|
||||
iftrue=(&syscc ne 0),
|
||||
msg=Cannot enter &sysmacroname with syscc=&syscc
|
||||
)
|
||||
|
||||
%local oauth_bearer;
|
||||
%if &grant_type=detect %then %do;
|
||||
%if %symexist(&access_token_var) %then %let grant_type=authorization_code;
|
||||
@@ -24447,6 +24463,11 @@ run;
|
||||
,mac=MV_CREATEFILE
|
||||
,msg=%str(File &path/&name already exists and force=&force)
|
||||
)
|
||||
%mp_abort(
|
||||
iftrue=(&syscc ne 0),
|
||||
mac=MV_CREATEFILE182
|
||||
msg=syscc=&syscc after mfv_getpathuri
|
||||
)
|
||||
|
||||
%if %mf_isblank(&fileuri)=0 and &force=YES %then %do;
|
||||
proc http method="DELETE" url="&base_uri&fileuri" &oauth_bearer;
|
||||
@@ -24516,8 +24537,8 @@ data &outds;
|
||||
end;
|
||||
run;
|
||||
|
||||
%put &sysmacroname: &name created at %mfv_getpathuri(&path/&name);%put;
|
||||
%put &base_uri/SASJobExecution?_file=&path/&name;%put;
|
||||
%put &sysmacroname: %trim(&base_uri)%mfv_getpathuri(&path/&name);
|
||||
%put /SASJobExecution?_file=&path/&name;%put;
|
||||
|
||||
%if &mdebug=0 %then %do;
|
||||
/* clear refs */
|
||||
@@ -24526,6 +24547,11 @@ run;
|
||||
libname &libref2 clear;
|
||||
%end;
|
||||
|
||||
%mp_abort(
|
||||
iftrue=(&syscc ne 0),
|
||||
msg=Cannot leave &sysmacroname with syscc=&syscc
|
||||
)
|
||||
|
||||
%mend mv_createfile;/**
|
||||
@file mv_createfolder.sas
|
||||
@brief Creates a viya folder if that folder does not already exist
|
||||
@@ -24574,6 +24600,11 @@ run;
|
||||
%end;
|
||||
%else %let dbg=*;
|
||||
|
||||
%mp_abort(
|
||||
iftrue=(&syscc ne 0),
|
||||
msg=Cannot enter &sysmacroname with syscc=&syscc
|
||||
)
|
||||
|
||||
%if %mfv_existfolder(&path)=1 %then %do;
|
||||
%&dbg.put &sysmacroname: &path already exists;
|
||||
data &outds;
|
||||
@@ -24583,6 +24614,7 @@ run;
|
||||
run;
|
||||
%return;
|
||||
%end;
|
||||
%mp_abort(iftrue=(&syscc ne 0),msg=syscc=&syscc when folder checking)
|
||||
|
||||
%local oauth_bearer;
|
||||
%if &grant_type=detect %then %do;
|
||||
@@ -24636,6 +24668,17 @@ options noquotelenmax;
|
||||
headers "Authorization"="Bearer &&&access_token_var";
|
||||
%end;
|
||||
run;
|
||||
%if &SYS_PROCHTTP_STATUS_CODE=401 %then %do;
|
||||
/* relates to: https://github.com/sasjs/core/issues/400 */
|
||||
%put 401 thrown in &sysmacroname;
|
||||
%put sleeping: %sysfunc(sleep(12,1)) secs - will try again;
|
||||
proc http method='GET' out=&fname1 &oauth_bearer
|
||||
url="&base_uri/folders/folders/@item?path=&newpath";
|
||||
%if &grant_type=authorization_code %then %do;
|
||||
headers "Authorization"="Bearer &&&access_token_var";
|
||||
%end;
|
||||
run;
|
||||
%end;
|
||||
%local libref1;
|
||||
%let libref1=%mf_getuniquelibref();
|
||||
libname &libref1 JSON fileref=&fname1;
|
||||
@@ -24643,7 +24686,7 @@ options noquotelenmax;
|
||||
iftrue=(
|
||||
&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 404
|
||||
)
|
||||
,mac=&sysmacroname
|
||||
,mac=mv_createfolder124
|
||||
,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
|
||||
)
|
||||
%if &mdebug=1 %then %do;
|
||||
@@ -24692,7 +24735,7 @@ options noquotelenmax;
|
||||
'Content-Type'='application/vnd.sas.content.folder+json'
|
||||
'Accept'='application/vnd.sas.content.folder+json';
|
||||
run;
|
||||
%if &SYS_PROCHTTP_STATUS_CODE ne 200 %then %do;
|
||||
%if &SYS_PROCHTTP_STATUS_CODE ne 201 %then %do;
|
||||
%put &=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
|
||||
%end;
|
||||
%mp_abort(iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 201)
|
||||
@@ -24722,6 +24765,10 @@ options noquotelenmax;
|
||||
filename &fname1 clear;
|
||||
libname &libref1 clear;
|
||||
%end;
|
||||
%mp_abort(
|
||||
iftrue=(&syscc ne 0),
|
||||
msg=Cannot leave &sysmacroname with syscc=&syscc
|
||||
)
|
||||
%mend mv_createfolder;/**
|
||||
@file
|
||||
@brief Creates a Viya Job
|
||||
|
||||
@@ -148,6 +148,6 @@ data _null_;
|
||||
run;
|
||||
|
||||
/* END */
|
||||
%put &sysmacroname took %sysevalf(%sysfunc(datetime())-&dttm) seconds to run;
|
||||
/* %put &sysmacroname took %sysevalf(%sysfunc(datetime())-&dttm) secs to run; */
|
||||
|
||||
%mend mp_replace;
|
||||
|
||||
@@ -33,16 +33,23 @@
|
||||
msg=Cannot enter mfv_existfolder.sas with syscc=&syscc
|
||||
)
|
||||
|
||||
%local fref rc;
|
||||
%local fref rc var;
|
||||
%let fref=%mf_getuniquefileref();
|
||||
|
||||
%if %sysfunc(filename(fref,,filesrvc,folderPath="&path"))=0 %then %do;
|
||||
1
|
||||
%let var=_FILESRVC_&fref._URI;
|
||||
%let rc=%sysfunc(filename(fref));
|
||||
%symdel &var;
|
||||
%end;
|
||||
%else %do;
|
||||
0
|
||||
%let syscc=0;
|
||||
%end;
|
||||
|
||||
%mf_abort(
|
||||
iftrue=(&syscc ne 0),
|
||||
msg=Cannot leave mfv_existfolder.sas with syscc=&syscc
|
||||
)
|
||||
|
||||
%mend mfv_existfolder;
|
||||
@@ -49,4 +49,8 @@
|
||||
%let syscc=0;
|
||||
%end;
|
||||
|
||||
%mf_abort(
|
||||
iftrue=(&syscc ne 0),
|
||||
msg=Cannot leave &sysmacroname with syscc=&syscc
|
||||
)
|
||||
%mend mfv_getpathuri;
|
||||
@@ -95,6 +95,11 @@
|
||||
%end;
|
||||
%else %let dbg=*;
|
||||
|
||||
%mp_abort(
|
||||
iftrue=(&syscc ne 0),
|
||||
msg=Cannot enter &sysmacroname with syscc=&syscc
|
||||
)
|
||||
|
||||
%local oauth_bearer;
|
||||
%if &grant_type=detect %then %do;
|
||||
%if %symexist(&access_token_var) %then %let grant_type=authorization_code;
|
||||
@@ -172,6 +177,11 @@ run;
|
||||
,mac=MV_CREATEFILE
|
||||
,msg=%str(File &path/&name already exists and force=&force)
|
||||
)
|
||||
%mp_abort(
|
||||
iftrue=(&syscc ne 0),
|
||||
mac=MV_CREATEFILE182
|
||||
msg=syscc=&syscc after mfv_getpathuri
|
||||
)
|
||||
|
||||
%if %mf_isblank(&fileuri)=0 and &force=YES %then %do;
|
||||
proc http method="DELETE" url="&base_uri&fileuri" &oauth_bearer;
|
||||
@@ -241,8 +251,8 @@ data &outds;
|
||||
end;
|
||||
run;
|
||||
|
||||
%put &sysmacroname: &name created at %mfv_getpathuri(&path/&name);%put;
|
||||
%put &base_uri/SASJobExecution?_file=&path/&name;%put;
|
||||
%put &sysmacroname: %trim(&base_uri)%mfv_getpathuri(&path/&name);
|
||||
%put /SASJobExecution?_file=&path/&name;%put;
|
||||
|
||||
%if &mdebug=0 %then %do;
|
||||
/* clear refs */
|
||||
@@ -251,4 +261,9 @@ run;
|
||||
libname &libref2 clear;
|
||||
%end;
|
||||
|
||||
%mp_abort(
|
||||
iftrue=(&syscc ne 0),
|
||||
msg=Cannot leave &sysmacroname with syscc=&syscc
|
||||
)
|
||||
|
||||
%mend mv_createfile;
|
||||
@@ -46,6 +46,11 @@
|
||||
%end;
|
||||
%else %let dbg=*;
|
||||
|
||||
%mp_abort(
|
||||
iftrue=(&syscc ne 0),
|
||||
msg=Cannot enter &sysmacroname with syscc=&syscc
|
||||
)
|
||||
|
||||
%if %mfv_existfolder(&path)=1 %then %do;
|
||||
%&dbg.put &sysmacroname: &path already exists;
|
||||
data &outds;
|
||||
@@ -55,6 +60,7 @@
|
||||
run;
|
||||
%return;
|
||||
%end;
|
||||
%mp_abort(iftrue=(&syscc ne 0),msg=syscc=&syscc when folder checking)
|
||||
|
||||
%local oauth_bearer;
|
||||
%if &grant_type=detect %then %do;
|
||||
@@ -108,6 +114,17 @@ options noquotelenmax;
|
||||
headers "Authorization"="Bearer &&&access_token_var";
|
||||
%end;
|
||||
run;
|
||||
%if &SYS_PROCHTTP_STATUS_CODE=401 %then %do;
|
||||
/* relates to: https://github.com/sasjs/core/issues/400 */
|
||||
%put 401 thrown in &sysmacroname;
|
||||
%put sleeping: %sysfunc(sleep(12,1)) secs - will try again;
|
||||
proc http method='GET' out=&fname1 &oauth_bearer
|
||||
url="&base_uri/folders/folders/@item?path=&newpath";
|
||||
%if &grant_type=authorization_code %then %do;
|
||||
headers "Authorization"="Bearer &&&access_token_var";
|
||||
%end;
|
||||
run;
|
||||
%end;
|
||||
%local libref1;
|
||||
%let libref1=%mf_getuniquelibref();
|
||||
libname &libref1 JSON fileref=&fname1;
|
||||
@@ -115,7 +132,7 @@ options noquotelenmax;
|
||||
iftrue=(
|
||||
&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 404
|
||||
)
|
||||
,mac=&sysmacroname
|
||||
,mac=mv_createfolder124
|
||||
,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
|
||||
)
|
||||
%if &mdebug=1 %then %do;
|
||||
@@ -164,7 +181,7 @@ options noquotelenmax;
|
||||
'Content-Type'='application/vnd.sas.content.folder+json'
|
||||
'Accept'='application/vnd.sas.content.folder+json';
|
||||
run;
|
||||
%if &SYS_PROCHTTP_STATUS_CODE ne 200 %then %do;
|
||||
%if &SYS_PROCHTTP_STATUS_CODE ne 201 %then %do;
|
||||
%put &=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
|
||||
%end;
|
||||
%mp_abort(iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 201)
|
||||
@@ -194,4 +211,8 @@ options noquotelenmax;
|
||||
filename &fname1 clear;
|
||||
libname &libref1 clear;
|
||||
%end;
|
||||
%mp_abort(
|
||||
iftrue=(&syscc ne 0),
|
||||
msg=Cannot leave &sysmacroname with syscc=&syscc
|
||||
)
|
||||
%mend mv_createfolder;
|
||||
Reference in New Issue
Block a user