mirror of
https://github.com/sasjs/core.git
synced 2026-01-03 23:50:06 +00:00
Compare commits
54 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d9f8e92fac | |||
|
|
d42ede15db | ||
|
|
08ea9f7c00 | ||
|
|
c327e1fc0d | ||
|
|
02fddcf9a1 | ||
|
|
4752bfbb05 | ||
|
|
767ddd7add | ||
|
|
54a24ced83 | ||
|
|
57ae2981f1 | ||
|
|
a3043ac685 | ||
|
|
2bdb90b0be | ||
|
|
2cd846d504 | ||
|
|
f593c7bec9 | ||
|
|
c8805db0b5 | ||
|
|
1eb6d8cec9 | ||
|
|
ed19ee03af | ||
|
|
a1c931b5e6 | ||
|
|
cb553a31ab | ||
|
|
557df272ff | ||
|
|
0cb3c96c15 | ||
|
|
1cb39d4d61 | ||
|
|
934b7d4f8a | ||
|
|
24c50cde56 | ||
|
|
055e8d2f13 | ||
|
|
abfe7fe339 | ||
|
|
16ed91f6a9 | ||
|
|
67ba2a5286 | ||
|
|
3d7f9b71e1 | ||
|
|
1d972fad11 | ||
|
|
e23bc461c4 | ||
|
|
28ed458b83 | ||
|
|
827210e010 | ||
|
|
de2f32da36 | ||
|
|
6fa0fc5dc6 | ||
|
|
73e3d9d419 | ||
|
|
5f2229e3d5 | ||
|
|
d19c4a517c | ||
|
|
c47480f60c | ||
|
|
295211bb72 | ||
|
|
818bc3cc2b | ||
|
|
bb6111e2b3 | ||
|
|
512f05c0b2 | ||
|
|
500fb8124f | ||
|
|
88ddba2a4b | ||
|
|
86f6d06b85 | ||
|
|
1cefc0e7ee | ||
|
|
412182a022 | ||
|
|
43b8ee1c7e | ||
|
|
83eea02240 | ||
|
|
a14e31804a | ||
|
|
3fa639ebf7 | ||
|
|
ed11d44fe8 | ||
|
|
de4ea8888f | ||
|
|
ea0a936871 |
8
.devcontainer/Dockerfile
Normal file
8
.devcontainer/Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.233.0/containers/javascript-node/.devcontainer/base.Dockerfile
|
||||||
|
|
||||||
|
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
|
||||||
|
ARG VARIANT="18-bullseye"
|
||||||
|
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y doxygen
|
||||||
26
.devcontainer/devcontainer.json
Normal file
26
.devcontainer/devcontainer.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
|
||||||
|
// https://github.com/microsoft/vscode-dev-containers/tree/v0.233.0/containers/typescript-node
|
||||||
|
{
|
||||||
|
"name": "Node.js & TypeScript",
|
||||||
|
"build": {
|
||||||
|
"dockerfile": "Dockerfile",
|
||||||
|
// Update 'VARIANT' to pick a Node version: 18, 16, 14.
|
||||||
|
// Append -bullseye or -buster to pin to an OS version.
|
||||||
|
// Use -bullseye variants on local on arm64/Apple Silicon.
|
||||||
|
"args": {
|
||||||
|
"VARIANT": "16-bullseye"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// Set *default* container specific settings.json values on container create.
|
||||||
|
"settings": {},
|
||||||
|
// Add the IDs of extensions you want installed when the container is created.
|
||||||
|
"extensions": [
|
||||||
|
"SASjs.sasjs-for-vscode"
|
||||||
|
],
|
||||||
|
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||||
|
// "forwardPorts": [],
|
||||||
|
// Use 'postCreateCommand' to run commands after the container is created.
|
||||||
|
"postCreateCommand": "npm i && npm i -g @sasjs/cli",
|
||||||
|
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
||||||
|
"remoteUser": "node"
|
||||||
|
}
|
||||||
94
README.md
94
README.md
@@ -31,14 +31,14 @@ Documentation: https://core.sasjs.io
|
|||||||
|
|
||||||
## Components
|
## Components
|
||||||
|
|
||||||
### BASE library (All Platforms)
|
### BASE folder (All Platforms)
|
||||||
|
|
||||||
- OS independent
|
- OS independent
|
||||||
- Works on all SAS Platforms
|
- Works on all SAS Platforms
|
||||||
- No X command
|
- No X command
|
||||||
- Prefixes: _mf_, _mp_
|
- Prefixes: _mf_, _mp_
|
||||||
|
|
||||||
### DDL library (All Platforms)
|
### DDL folder (All Platforms)
|
||||||
|
|
||||||
- OS independent
|
- OS independent
|
||||||
- Works on all SAS Platforms
|
- Works on all SAS Platforms
|
||||||
@@ -47,46 +47,14 @@ Documentation: https://core.sasjs.io
|
|||||||
|
|
||||||
This library will not be used for storing data entries (such as formats or datalines). Where this becomes necessary in the future, a new repo will be created, in order to keep the NPM bundle size down (for the benefit of those looking to embed purely macros in their applications).
|
This library will not be used for storing data entries (such as formats or datalines). Where this becomes necessary in the future, a new repo will be created, in order to keep the NPM bundle size down (for the benefit of those looking to embed purely macros in their applications).
|
||||||
|
|
||||||
### FCMP library (All Platforms)
|
### FCMP folder (All Platforms)
|
||||||
|
|
||||||
- Function and macro names are identical, except for special cases
|
- Function and macro names are identical, except for special cases
|
||||||
- Prefixes: _mcf_
|
- Prefixes: _mcf_
|
||||||
|
|
||||||
The fcmp macros are used to generate fcmp functions, and can be used with or without the `proc fcmp` wrapper.
|
The fcmp macros are used to generate fcmp functions, and can be used with or without the `proc fcmp` wrapper.
|
||||||
|
|
||||||
### META library (SAS9 only)
|
### LUA folder
|
||||||
|
|
||||||
Macros used in SAS EBI, which connect to the metadata server.
|
|
||||||
|
|
||||||
- OS independent
|
|
||||||
- Metadata aware
|
|
||||||
- No X command
|
|
||||||
- Prefixes: _mm_
|
|
||||||
|
|
||||||
### SERVER library (@sasjs/server only)
|
|
||||||
These macros are used for building applications using [@sasjs/server](https://server.sasjs.io) - an open source REST API for Desktop SAS.
|
|
||||||
|
|
||||||
- OS independent
|
|
||||||
- @sasjs/server aware
|
|
||||||
- No X command
|
|
||||||
- Prefixes: _ms_
|
|
||||||
|
|
||||||
### VIYA library (Viya only)
|
|
||||||
|
|
||||||
Macros used for interfacing with SAS Viya.
|
|
||||||
|
|
||||||
- OS independent
|
|
||||||
- No X command
|
|
||||||
- Prefixes: _mv_, _mvf_
|
|
||||||
|
|
||||||
### METAX library (SAS9 only)
|
|
||||||
|
|
||||||
- OS specific
|
|
||||||
- Metadata aware
|
|
||||||
- X command enabled
|
|
||||||
- Prefixes: _mmw_,_mmu_,_mmx_
|
|
||||||
|
|
||||||
### LUA library
|
|
||||||
|
|
||||||
Wait - this is a macro library - what is LUA doing here? Well, it is a little known fact that you CAN run LUA within a SAS Macro. It has to be written to a text file with a `.lua` extension, from where you can `%include` it. So, without using the `proc lua` wrapper.
|
Wait - this is a macro library - what is LUA doing here? Well, it is a little known fact that you CAN run LUA within a SAS Macro. It has to be written to a text file with a `.lua` extension, from where you can `%include` it. So, without using the `proc lua` wrapper.
|
||||||
|
|
||||||
@@ -106,13 +74,61 @@ run;
|
|||||||
|
|
||||||
- Prefixes: _ml_
|
- Prefixes: _ml_
|
||||||
|
|
||||||
|
### META folder (SAS9 only)
|
||||||
|
|
||||||
|
Macros used in SAS EBI, which connect to the metadata server.
|
||||||
|
|
||||||
|
- OS independent
|
||||||
|
- Metadata aware
|
||||||
|
- No X command
|
||||||
|
- Prefixes: _mm_
|
||||||
|
|
||||||
|
### METAX folder (SAS9 only)
|
||||||
|
|
||||||
|
- OS specific
|
||||||
|
- Metadata aware
|
||||||
|
- X command enabled
|
||||||
|
- Prefixes: _mmw_,_mmu_,_mmx_
|
||||||
|
|
||||||
|
### SERVER folder (@sasjs/server only)
|
||||||
|
These macros are used for building applications using [@sasjs/server](https://server.sasjs.io) - an open source REST API for Desktop SAS.
|
||||||
|
|
||||||
|
- OS independent
|
||||||
|
- @sasjs/server aware
|
||||||
|
- No X command
|
||||||
|
- Prefixes: _ms_
|
||||||
|
|
||||||
|
### VIYA folder (Viya only)
|
||||||
|
|
||||||
|
Macros used for interfacing with SAS Viya.
|
||||||
|
|
||||||
|
- OS independent
|
||||||
|
- No X command
|
||||||
|
- Prefixes: _mv_, _mvf_
|
||||||
|
|
||||||
|
### XPLATFORM folder (Viya, Meta, and Server)
|
||||||
|
|
||||||
|
Sometimes it is helpful to use a macro that can be used interchangeably regardless of the server type on which is is running (SASVIYA, SAS9, SASJS).
|
||||||
|
|
||||||
|
- OS independent
|
||||||
|
- No X command
|
||||||
|
- Prefixes: _mx_
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
First, download the repo to a location your SAS system can access. Then update your sasautos path to include the components you wish to have available, eg:
|
First, download the repo to a location your SAS system can access. Then update your sasautos path to include the components you wish to have available, eg:
|
||||||
|
|
||||||
```sas
|
```sas
|
||||||
options insert=(sasautos="/your/path/macrocore/base");
|
%let repoloc=/your/path/core;
|
||||||
options insert=(sasautos="/your/path/macrocore/meta");
|
options insert=(sasautos="&repoloc/base");
|
||||||
|
options insert=(sasautos="&repoloc/ddl");
|
||||||
|
options insert=(sasautos="&repoloc/fcmp");
|
||||||
|
options insert=(sasautos="&repoloc/lua");
|
||||||
|
options insert=(sasautos="&repoloc/meta");
|
||||||
|
options insert=(sasautos="&repoloc/metax");
|
||||||
|
options insert=(sasautos="&repoloc/server");
|
||||||
|
options insert=(sasautos="&repoloc/viya");
|
||||||
|
options insert=(sasautos="&repoloc/xplatform");
|
||||||
```
|
```
|
||||||
|
|
||||||
The above can be done directly in your sas program, via an autoexec, or an initialisation program.
|
The above can be done directly in your sas program, via an autoexec, or an initialisation program.
|
||||||
@@ -142,7 +158,7 @@ filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
|
|||||||
- _mp_ for macro procedures (which generate sas code)
|
- _mp_ for macro procedures (which generate sas code)
|
||||||
- _ms_ for macro procedures that will only work with [@sasjs/server](https://github.com/sasjs/server)
|
- _ms_ for macro procedures that will only work with [@sasjs/server](https://github.com/sasjs/server)
|
||||||
- _mv_ for macro procedures that will only work in Viya
|
- _mv_ for macro procedures that will only work in Viya
|
||||||
- _mx_ for macros that are XCMD enabled (working on both windows and unix)
|
- _mx_ for macros that work on Viya, SAS 9 EBI and SASjs Server
|
||||||
- follow verb-noun convention
|
- follow verb-noun convention
|
||||||
- unix style line endings (lf)
|
- unix style line endings (lf)
|
||||||
- individual lines should be no more than 80 characters long
|
- individual lines should be no more than 80 characters long
|
||||||
|
|||||||
@@ -40,6 +40,12 @@
|
|||||||
%else %if "&SYSVLONG" < "9.04.01M3" %then 0;
|
%else %if "&SYSVLONG" < "9.04.01M3" %then 0;
|
||||||
%else 1;
|
%else 1;
|
||||||
%end;
|
%end;
|
||||||
|
%else %if &feature=EXPORTXLS %then %do;
|
||||||
|
/* is it possible to PROC EXPORT an excel file? */
|
||||||
|
%if "%substr(&sysver,1,1)"="4" or "%substr(&sysver,1,1)"="5" %then 1;
|
||||||
|
%else %if %sysfunc(sysprod(SAS/ACCESS Interface to PC Files)) = 1 %then 1;
|
||||||
|
%else 0;
|
||||||
|
%end;
|
||||||
%else %do;
|
%else %do;
|
||||||
-1
|
-1
|
||||||
%put &sysmacroname: &feature not found;
|
%put &sysmacroname: &feature not found;
|
||||||
|
|||||||
@@ -6,9 +6,6 @@
|
|||||||
|
|
||||||
%put %mf_existVarList(sashelp.class, age sex name dummyvar);
|
%put %mf_existVarList(sashelp.class, age sex name dummyvar);
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
|
||||||
@li mf_abort.sas
|
|
||||||
|
|
||||||
@param libds 2 part dataset or view reference
|
@param libds 2 part dataset or view reference
|
||||||
@param varlist space separated variable names
|
@param varlist space separated variable names
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,12 @@
|
|||||||
|
|
||||||
%put %mf_getplatform();
|
%put %mf_getplatform();
|
||||||
|
|
||||||
returns:
|
returns one of:
|
||||||
SASMETA (or SASVIYA)
|
|
||||||
|
@li SASMETA
|
||||||
|
@li SASVIYA
|
||||||
|
@li SASJS
|
||||||
|
@li BASESAS
|
||||||
|
|
||||||
@param switch the param for which to return a platform specific variable
|
@param switch the param for which to return a platform specific variable
|
||||||
|
|
||||||
@@ -68,4 +72,4 @@
|
|||||||
%else %if &switch=VIYARESTAPI %then %do;
|
%else %if &switch=VIYARESTAPI %then %do;
|
||||||
%mf_trimstr(%sysfunc(getoption(servicesbaseurl)),/)
|
%mf_trimstr(%sysfunc(getoption(servicesbaseurl)),/)
|
||||||
%end;
|
%end;
|
||||||
%mend mf_getplatform;
|
%mend mf_getplatform;
|
||||||
|
|||||||
@@ -23,18 +23,19 @@
|
|||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
**/
|
**/
|
||||||
|
|
||||||
%macro mf_getuser(type=META
|
%macro mf_getuser(
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
%local user metavar;
|
%local user;
|
||||||
%if &type=OS %then %let metavar=_secureusername;
|
|
||||||
%else %let metavar=_metaperson;
|
|
||||||
|
|
||||||
%if %symexist(SYS_COMPUTE_SESSION_OWNER) %then %let user=&SYS_COMPUTE_SESSION_OWNER;
|
%if %symexist(_sasjs_username) %then %let user=&_sasjs_username;
|
||||||
%else %if %symexist(&metavar) %then %do;
|
%else %if %symexist(SYS_COMPUTE_SESSION_OWNER) %then %do;
|
||||||
%if %length(&&&metavar)=0 %then %let user=&sysuserid;
|
%let user=&SYS_COMPUTE_SESSION_OWNER;
|
||||||
|
%end;
|
||||||
|
%else %if %symexist(_metaperson) %then %do;
|
||||||
|
%if %length(&_metaperson)=0 %then %let user=&sysuserid;
|
||||||
/* sometimes SAS will add @domain extension - remove for consistency */
|
/* sometimes SAS will add @domain extension - remove for consistency */
|
||||||
/* but be sure to quote in case of usernames with commas */
|
/* but be sure to quote in case of usernames with commas */
|
||||||
%else %let user=%unquote(%scan(%quote(&&&metavar),1,@));
|
%else %let user=%unquote(%scan(%quote(&_metaperson),1,@));
|
||||||
%end;
|
%end;
|
||||||
%else %let user=&sysuserid;
|
%else %let user=&sysuserid;
|
||||||
|
|
||||||
|
|||||||
@@ -33,4 +33,4 @@
|
|||||||
%if %sysfunc(findc(%str(&val),,kd)) %then %do;0%end;
|
%if %sysfunc(findc(%str(&val),,kd)) %then %do;0%end;
|
||||||
%else %do;1%end;
|
%else %do;1%end;
|
||||||
|
|
||||||
%mend mf_isint;
|
%mend mf_isint;
|
||||||
|
|||||||
@@ -15,16 +15,20 @@
|
|||||||
recognise this and fetch the log of the parent session instead)
|
recognise this and fetch the log of the parent session instead)
|
||||||
@li STP environments must finish cleanly to avoid the log being sent to
|
@li STP environments must finish cleanly to avoid the log being sent to
|
||||||
_webout. To assist with this, we also run stpsrvset('program error', 0)
|
_webout. To assist with this, we also run stpsrvset('program error', 0)
|
||||||
and set SYSCC=0. We take a unique "soft abort" approach - we open a macro
|
and set SYSCC=0.
|
||||||
|
Where possible, we take a unique "soft abort" approach - we open a macro
|
||||||
but don't close it! This works everywhere EXCEPT inside a \%include inside
|
but don't close it! This works everywhere EXCEPT inside a \%include inside
|
||||||
a macro. For that, we recommend you use mp_include.sas to perform the
|
a macro. For that, we recommend you use mp_include.sas to perform the
|
||||||
include, and then call \%mp_abort(mode=INCLUDE) from the source program (ie,
|
include, and then call \%mp_abort(mode=INCLUDE) from the source program (ie,
|
||||||
OUTSIDE of the top-parent macro).
|
OUTSIDE of the top-parent macro).
|
||||||
|
The soft abort has also been found to be ineffective in 9.4m6 windows
|
||||||
|
environments and above, so in these cases, endsas is used.
|
||||||
|
|
||||||
|
|
||||||
@param mac= to contain the name of the calling macro
|
@param mac= (mp_abort.sas) To contain the name of the calling macro. Do not
|
||||||
|
use &sysmacroname as this will always resolve to MP_ABORT.
|
||||||
@param msg= message to be returned
|
@param msg= message to be returned
|
||||||
@param iftrue= supply a condition under which the macro should be executed.
|
@param iftrue= (1=1) Supply a condition for which the macro should be executed
|
||||||
@param errds= (work.mp_abort_errds) There is no clean way to end a process
|
@param errds= (work.mp_abort_errds) There is no clean way to end a process
|
||||||
within a %include called within a macro. Furthermore, there is no way to
|
within a %include called within a macro. Furthermore, there is no way to
|
||||||
test if a macro is called within a %include. To handle this particular
|
test if a macro is called within a %include. To handle this particular
|
||||||
@@ -45,11 +49,12 @@
|
|||||||
@li REGULAR (default)
|
@li REGULAR (default)
|
||||||
@li INCLUDE
|
@li INCLUDE
|
||||||
|
|
||||||
|
@version 9.4
|
||||||
|
@author Allan Bowe
|
||||||
|
|
||||||
<h4> Related Macros </h4>
|
<h4> Related Macros </h4>
|
||||||
@li mp_include.sas
|
@li mp_include.sas
|
||||||
|
|
||||||
@version 9.4
|
|
||||||
@author Allan Bowe
|
|
||||||
@cond
|
@cond
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@@ -58,7 +63,8 @@
|
|||||||
, mode=REGULAR
|
, mode=REGULAR
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
%global sysprocessmode sysprocessname;
|
%global sysprocessmode sysprocessname sasjs_stpsrv_header_loc;
|
||||||
|
%local fref fid i;
|
||||||
|
|
||||||
%if not(%eval(%unquote(&iftrue))) %then %return;
|
%if not(%eval(%unquote(&iftrue))) %then %return;
|
||||||
|
|
||||||
@@ -68,7 +74,7 @@
|
|||||||
|
|
||||||
%if %symexist(_SYSINCLUDEFILEDEVICE)
|
%if %symexist(_SYSINCLUDEFILEDEVICE)
|
||||||
/* abort cancel FILE does not restart outside the INCLUDE on Viya 3.5 */
|
/* abort cancel FILE does not restart outside the INCLUDE on Viya 3.5 */
|
||||||
and "&SYSPROCESSNAME " ne "Compute Server "
|
and %superq(SYSPROCESSNAME) ne %str(Compute Server)
|
||||||
%then %do;
|
%then %do;
|
||||||
%if "*&_SYSINCLUDEFILEDEVICE*" ne "**" %then %do;
|
%if "*&_SYSINCLUDEFILEDEVICE*" ne "**" %then %do;
|
||||||
data &errds;
|
data &errds;
|
||||||
@@ -84,9 +90,9 @@
|
|||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
/* Stored Process Server web app context */
|
/* Web App Context */
|
||||||
%if %symexist(_METAFOLDER)
|
%if %symexist(_PROGRAM)
|
||||||
or "&SYSPROCESSNAME "="Compute Server "
|
or %superq(SYSPROCESSNAME) = %str(Compute Server)
|
||||||
or &mode=INCLUDE
|
or &mode=INCLUDE
|
||||||
%then %do;
|
%then %do;
|
||||||
options obs=max replace mprint;
|
options obs=max replace mprint;
|
||||||
@@ -152,8 +158,8 @@
|
|||||||
%end;
|
%end;
|
||||||
|
|
||||||
%if %symexist(SYS_JES_JOB_URI) %then %do;
|
%if %symexist(SYS_JES_JOB_URI) %then %do;
|
||||||
/* setup webout */
|
/* setup webout for Viya */
|
||||||
OPTIONS NOBOMFILE;
|
options nobomfile;
|
||||||
%if "X&SYS_JES_JOB_URI.X"="XX" %then %do;
|
%if "X&SYS_JES_JOB_URI.X"="XX" %then %do;
|
||||||
filename _webout temp lrecl=999999 mod;
|
filename _webout temp lrecl=999999 mod;
|
||||||
%end;
|
%end;
|
||||||
@@ -162,11 +168,24 @@
|
|||||||
name="_webout.json" lrecl=999999 mod;
|
name="_webout.json" lrecl=999999 mod;
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
|
%else %if %sysfunc(filename(fref,&sasjs_stpsrv_header_loc))=0 %then %do;
|
||||||
|
options nobomfile;
|
||||||
|
/* set up http header for SASjs Server */
|
||||||
|
%let fid=%sysfunc(fopen(&fref,A));
|
||||||
|
%if &fid=0 %then %do;
|
||||||
|
%put %str(ERR)OR: %sysfunc(sysmsg());
|
||||||
|
%return;
|
||||||
|
%end;
|
||||||
|
%let rc=%sysfunc(fput(&fid,%str(Content-Type: application/json)));
|
||||||
|
%let rc=%sysfunc(fwrite(&fid));
|
||||||
|
%let rc=%sysfunc(fclose(&fid));
|
||||||
|
%let rc=%sysfunc(filename(&fref));
|
||||||
|
%end;
|
||||||
|
|
||||||
/* send response in SASjs JSON format */
|
/* send response in SASjs JSON format */
|
||||||
data _null_;
|
data _null_;
|
||||||
file _webout mod lrecl=32000 encoding='utf-8';
|
file _webout mod lrecl=32000 encoding='utf-8';
|
||||||
length msg syswarningtext syserrortext $32767 ;
|
length msg syswarningtext syserrortext $32767 mode $10 ;
|
||||||
sasdatetime=datetime();
|
sasdatetime=datetime();
|
||||||
msg=symget('msg');
|
msg=symget('msg');
|
||||||
%if &logline>0 %then %do;
|
%if &logline>0 %then %do;
|
||||||
@@ -182,7 +201,8 @@
|
|||||||
msg=cats('"',msg,'"');
|
msg=cats('"',msg,'"');
|
||||||
if symexist('_debug') then debug=quote(trim(symget('_debug')));
|
if symexist('_debug') then debug=quote(trim(symget('_debug')));
|
||||||
else debug='""';
|
else debug='""';
|
||||||
put '>>weboutBEGIN<<';
|
if symget('sasjsprocessmode')='Stored Program' then mode='SASJS';
|
||||||
|
if mode ne 'SASJS' then put '>>weboutBEGIN<<';
|
||||||
put '{"SYSDATE" : "' "&SYSDATE" '"';
|
put '{"SYSDATE" : "' "&SYSDATE" '"';
|
||||||
put ',"SYSTIME" : "' "&SYSTIME" '"';
|
put ',"SYSTIME" : "' "&SYSTIME" '"';
|
||||||
put ',"sasjsAbort" : [{';
|
put ',"sasjsAbort" : [{';
|
||||||
@@ -214,8 +234,8 @@
|
|||||||
syswarningtext=quote(trim(symget('syswarningtext')));
|
syswarningtext=quote(trim(symget('syswarningtext')));
|
||||||
put ",""SYSWARNINGTEXT"" : " syswarningtext;
|
put ",""SYSWARNINGTEXT"" : " syswarningtext;
|
||||||
put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
|
put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
|
||||||
put "}" @;
|
put "}" ;
|
||||||
put '>>weboutEND<<';
|
if mode ne 'SASJS' then put '>>weboutEND<<';
|
||||||
run;
|
run;
|
||||||
|
|
||||||
%put _all_;
|
%put _all_;
|
||||||
@@ -226,22 +246,30 @@
|
|||||||
rc=stpsrvset('program error', 0);
|
rc=stpsrvset('program error', 0);
|
||||||
call symputx("syscc",0,"g");
|
call symputx("syscc",0,"g");
|
||||||
run;
|
run;
|
||||||
/**
|
%if &sysscp=WIN
|
||||||
* endsas kills 9.4m3 deployments by orphaning multibridges.
|
and "%substr(%str(&sysvlong ),1,8)"="9.04.01M"
|
||||||
* Abort variants are ungraceful (non zero return code)
|
and "%substr(%str(&sysvlong ),9,1)">"5" %then %do;
|
||||||
* This approach lets SAS run silently until the end :-)
|
/* skip approach (below) does not work in windows m6+ envs */
|
||||||
* Caution - fails when called within a %include within a macro
|
endsas;
|
||||||
* Use mp_include() to handle this.
|
%end;
|
||||||
*/
|
%else %do;
|
||||||
filename skip temp;
|
/**
|
||||||
data _null_;
|
* endsas kills 9.4m3 deployments by orphaning multibridges.
|
||||||
file skip;
|
* Abort variants are ungraceful (non zero return code)
|
||||||
put '%macro skip();';
|
* This approach lets SAS run silently until the end :-)
|
||||||
comment '%mend skip; -> fix lint ';
|
* Caution - fails when called within a %include within a macro
|
||||||
put '%macro skippy();';
|
* Use mp_include() to handle this.
|
||||||
comment '%mend skippy; -> fix lint ';
|
*/
|
||||||
run;
|
filename skip temp;
|
||||||
%inc skip;
|
data _null_;
|
||||||
|
file skip;
|
||||||
|
put '%macro skip();';
|
||||||
|
comment '%mend skip; -> fix lint ';
|
||||||
|
put '%macro skippy();';
|
||||||
|
comment '%mend skippy; -> fix lint ';
|
||||||
|
run;
|
||||||
|
%inc skip;
|
||||||
|
%end;
|
||||||
%end;
|
%end;
|
||||||
%else %if "&sysprocessmode " = "SAS Compute Server " %then %do;
|
%else %if "&sysprocessmode " = "SAS Compute Server " %then %do;
|
||||||
/* endsas kills the session making it harder to fetch results */
|
/* endsas kills the session making it harder to fetch results */
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
@li mddl_dc_filtersummary.sas
|
@li mddl_dc_filtersummary.sas
|
||||||
@li mddl_dc_locktable.sas
|
@li mddl_dc_locktable.sas
|
||||||
@li mddl_dc_maxkeytable.sas
|
@li mddl_dc_maxkeytable.sas
|
||||||
|
@li mf_getuniquename.sas
|
||||||
|
|
||||||
<h4> Related Macros </h4>
|
<h4> Related Macros </h4>
|
||||||
@li mp_filterstore.sas
|
@li mp_filterstore.sas
|
||||||
@@ -46,7 +47,7 @@
|
|||||||
%macro mp_coretable(table_ref,libds=0
|
%macro mp_coretable(table_ref,libds=0
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
%local outds ;
|
%local outds ;
|
||||||
%let outds=%sysfunc(ifc(&libds=0,_data_,&libds));
|
%let outds=%sysfunc(ifc(&libds=0,%mf_getuniquename(),&libds));
|
||||||
proc sql;
|
proc sql;
|
||||||
%if &table_ref=DIFFTABLE %then %do;
|
%if &table_ref=DIFFTABLE %then %do;
|
||||||
%mddl_dc_difftable(libds=&outds)
|
%mddl_dc_difftable(libds=&outds)
|
||||||
|
|||||||
@@ -1,50 +1,13 @@
|
|||||||
/**
|
/**
|
||||||
@file mp_createwebservice.sas
|
@file mp_createwebservice.sas
|
||||||
@brief Create a web service in SAS 9 or Viya
|
@brief Create a web service in SAS 9, Viya or SASjs Server
|
||||||
@details Creates a SASJS ready Stored Process in SAS 9 or Job Execution
|
@details This is actually a wrapper for mx_createwebservice.sas, remaining
|
||||||
Service in SAS Viya
|
for legacy purposes. For new apps, use mx_createwebservice.sas.
|
||||||
|
|
||||||
Usage:
|
|
||||||
|
|
||||||
%* compile macros ;
|
|
||||||
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
|
|
||||||
%inc mc;
|
|
||||||
|
|
||||||
%* write some code;
|
|
||||||
filename ft15f001 temp;
|
|
||||||
parmcards4;
|
|
||||||
%* fetch any data from frontend ;
|
|
||||||
%webout(FETCH)
|
|
||||||
data example1 example2;
|
|
||||||
set sashelp.class;
|
|
||||||
run;
|
|
||||||
%* send data back;
|
|
||||||
%webout(OPEN)
|
|
||||||
%webout(ARR,example1) * Array format, fast, suitable for large tables ;
|
|
||||||
%webout(OBJ,example2) * Object format, easier to work with ;
|
|
||||||
%webout(CLOSE)
|
|
||||||
;;;;
|
|
||||||
%mp_createwebservice(path=/Public/app/common,name=appInit,replace=YES)
|
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_getplatform.sas
|
@li mx_createwebservice.sas
|
||||||
@li mm_createwebservice.sas
|
|
||||||
@li ms_createwebservice.sas
|
|
||||||
@li mv_createwebservice.sas
|
|
||||||
|
|
||||||
@param [in,out] path= The full folder path where the service will be created
|
|
||||||
@param [in,out] name= Service name. Avoid spaces.
|
|
||||||
@param [in] desc= The description of the service (optional)
|
|
||||||
@param [in] precode= Space separated list of filerefs, pointing to the code
|
|
||||||
that needs to be attached to the beginning of the service (optional)
|
|
||||||
@param [in] code= (ft15f001) Space seperated fileref(s) of the actual code to
|
|
||||||
be added
|
|
||||||
@param [in] replace= (YES) Select YES to replace any existing service in that
|
|
||||||
location
|
|
||||||
@param [in] mDebug= (0) set to 1 to show debug messages in the log
|
|
||||||
|
|
||||||
@version 9.2
|
|
||||||
@author Allan Bowe
|
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@@ -57,40 +20,13 @@ Usage:
|
|||||||
,mdebug=0
|
,mdebug=0
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
%if &syscc ge 4 %then %do;
|
%mx_createwebservice(path=&path
|
||||||
%put syscc=&syscc - &sysmacroname will not execute in this state;
|
|
||||||
%return;
|
|
||||||
%end;
|
|
||||||
|
|
||||||
%local platform; %let platform=%mf_getplatform();
|
|
||||||
%if &platform=SASVIYA %then %do;
|
|
||||||
%if "&path"="HOME" %then %let path=/Users/&sysuserid/My Folder;
|
|
||||||
%mv_createwebservice(path=&path
|
|
||||||
,name=&name
|
,name=&name
|
||||||
,code=&code
|
|
||||||
,precode=&precode
|
,precode=&precode
|
||||||
|
,code=&code
|
||||||
,desc=&desc
|
,desc=&desc
|
||||||
,replace=&replace
|
,replace=&replace
|
||||||
)
|
|
||||||
%end;
|
|
||||||
%else %if &platform=SASJS %then %do;
|
|
||||||
%if "&path"="HOME" %then %let path=/Users/&_sasjs_username/My Folder;
|
|
||||||
%ms_createwebservice(path=&path
|
|
||||||
,name=&name
|
|
||||||
,code=&code
|
|
||||||
,precode=&precode
|
|
||||||
,mdebug=&mdebug
|
,mdebug=&mdebug
|
||||||
)
|
)
|
||||||
%end;
|
|
||||||
%else %do;
|
|
||||||
%if "&path"="HOME" %then %let path=/User Folders/&_METAPERSON/My Folder;
|
|
||||||
%mm_createwebservice(path=&path
|
|
||||||
,name=&name
|
|
||||||
,code=&code
|
|
||||||
,precode=&precode
|
|
||||||
,desc=&desc
|
|
||||||
,replace=&replace
|
|
||||||
)
|
|
||||||
%end;
|
|
||||||
|
|
||||||
%mend mp_createwebservice;
|
%mend mp_createwebservice;
|
||||||
|
|||||||
@@ -57,6 +57,11 @@
|
|||||||
%local vars;
|
%local vars;
|
||||||
%let vars=%upcase(%mf_getvarlist(&libds));
|
%let vars=%upcase(%mf_getvarlist(&libds));
|
||||||
|
|
||||||
|
%if %trim(X&vars)=X %then %do;
|
||||||
|
%put &sysmacroname: Table &libds has no columns!!;
|
||||||
|
%return;
|
||||||
|
%end;
|
||||||
|
|
||||||
/* create the header row */
|
/* create the header row */
|
||||||
data _null_;
|
data _null_;
|
||||||
file &outref;
|
file &outref;
|
||||||
|
|||||||
@@ -231,7 +231,7 @@
|
|||||||
%do i=1 %to &numcols;
|
%do i=1 %to &numcols;
|
||||||
%if &i>1 %then "," ;
|
%if &i>1 %then "," ;
|
||||||
%if &action=OBJ %then """&&name&i"":" ;
|
%if &action=OBJ %then """&&name&i"":" ;
|
||||||
&&name&i
|
"&&name&i"n /* name literal for reserved variable names */
|
||||||
%end;
|
%end;
|
||||||
%if &action=ARR %then "]" ; %else "}" ; ;
|
%if &action=ARR %then "]" ; %else "}" ; ;
|
||||||
/* now write the long strings to _webout 1 byte at a time */
|
/* now write the long strings to _webout 1 byte at a time */
|
||||||
|
|||||||
@@ -21,15 +21,19 @@ https://blogs.sas.com/content/sastraining/2012/08/14/jedi-sas-tricks-reset-sas-s
|
|||||||
%macro mp_resetoption(option /* the option to reset */
|
%macro mp_resetoption(option /* the option to reset */
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
data _null_;
|
%if "%substr(&sysver,1,1)" ne "4" and "%substr(&sysver,1,1)" ne "5" %then %do;
|
||||||
length code $1500;
|
data _null_;
|
||||||
startup=getoption("&option",'startupvalue');
|
length code $1500;
|
||||||
current=getoption("&option");
|
startup=getoption("&option",'startupvalue');
|
||||||
if startup ne current then do;
|
current=getoption("&option");
|
||||||
code =cat('OPTIONS ',getoption("&option",'keyword','startupvalue'),';');
|
if startup ne current then do;
|
||||||
putlog "NOTE: Resetting system option: " code ;
|
code =cat('OPTIONS ',getoption("&option",'keyword','startupvalue'),';');
|
||||||
call execute(code );
|
putlog "NOTE: Resetting system option: " code ;
|
||||||
end;
|
call execute(code );
|
||||||
run;
|
end;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
%put &sysmacroname: reset option feature unavailable on &sysvlong;
|
||||||
|
%end;
|
||||||
%mend mp_resetoption;
|
%mend mp_resetoption;
|
||||||
@@ -1,53 +1,11 @@
|
|||||||
/**
|
/**
|
||||||
@file
|
@file
|
||||||
@brief Will execute a SASjs web service on SAS 9 or Viya
|
@brief To be deprecated. Will execute a SASjs web service on SAS 9 or Viya
|
||||||
@details Prepares the input files and retrieves the resulting datasets from
|
@details Use the mx_testservice.sas macro instead (documentation can be
|
||||||
the response JSON.
|
found there)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Note - the _webout fileref should NOT be assigned prior to running this macro.
|
|
||||||
|
|
||||||
@param [in] program The _PROGRAM endpoint to test
|
|
||||||
@param [in] inputfiles=(0) A list of space seperated fileref:filename pairs as
|
|
||||||
follows:
|
|
||||||
inputfiles=inref:filename inref2:filename2
|
|
||||||
@param [in] inputdatasets= (0) All datasets in this space seperated list are
|
|
||||||
converted into SASJS-formatted CSVs (see mp_ds2csv.sas) files and added to
|
|
||||||
the list of `inputfiles` for ingestion. The dataset will be sent with the
|
|
||||||
same name (no need for a colon modifier).
|
|
||||||
@param [in] inputparams=(0) A dataset containing name/value pairs in the
|
|
||||||
following format:
|
|
||||||
|name:$32|value:$1000|
|
|
||||||
|---|---|
|
|
||||||
|stpmacname|some value|
|
|
||||||
|mustbevalidname|can be anything, oops, %abort!!|
|
|
||||||
|
|
||||||
@param [in] debug= (log) Provide the _debug value
|
|
||||||
@param [in] mdebug= (0) Set to 1 to provide macro debugging
|
|
||||||
@param [in] viyaresult= (WEBOUT_JSON) The Viya result type to return. For
|
|
||||||
more info, see mv_getjobresult.sas
|
|
||||||
@param [in] viyacontext= (SAS Job Execution compute context) The Viya compute
|
|
||||||
context on which to run the service
|
|
||||||
@param [out] outlib= (0) Output libref to contain the final tables. Set to
|
|
||||||
0 if the service output is not in JSON format.
|
|
||||||
@param [out] outref= (0) Output fileref to create, to contain the full _webout
|
|
||||||
response.
|
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_getplatform.sas
|
@li mx_testservice.sas
|
||||||
@li mf_getuniquefileref.sas
|
|
||||||
@li mf_getuniquename.sas
|
|
||||||
@li mp_abort.sas
|
|
||||||
@li mp_binarycopy.sas
|
|
||||||
@li mp_chop.sas
|
|
||||||
@li mp_ds2csv.sas
|
|
||||||
@li ms_testservice.sas
|
|
||||||
@li mv_getjobresult.sas
|
|
||||||
@li mv_jobflow.sas
|
|
||||||
|
|
||||||
<h4> Related Programs </h4>
|
|
||||||
@li mp_testservice.test.sas
|
|
||||||
|
|
||||||
@version 9.4
|
@version 9.4
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
@@ -65,237 +23,17 @@
|
|||||||
viyaresult=WEBOUT_JSON,
|
viyaresult=WEBOUT_JSON,
|
||||||
viyacontext=SAS Job Execution compute context
|
viyacontext=SAS Job Execution compute context
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
%local dbg pcnt fref1 fref2 webref webrefpath i webcount var platform;
|
|
||||||
%if &mdebug=1 %then %do;
|
|
||||||
%put &sysmacroname entry vars:;
|
|
||||||
%put _local_;
|
|
||||||
%end;
|
|
||||||
%else %let dbg=*;
|
|
||||||
|
|
||||||
/* sanitise inputparams */
|
%mx_testservice(&program,
|
||||||
%let pcnt=0;
|
inputfiles=&inputfiles,
|
||||||
%if &inputparams ne 0 %then %do;
|
inputdatasets=&inputdatasets,
|
||||||
data _null_;
|
inputparams=&inputparams,
|
||||||
set &inputparams;
|
debug=&debug,
|
||||||
if not nvalid(name,'v7') then putlog (_all_)(=);
|
mdebug=&mdebug,
|
||||||
else if name in (
|
outlib=&outlib,
|
||||||
'program','inputfiles','inputparams','debug','outlib','outref'
|
outref=&outref,
|
||||||
) then putlog (_all_)(=);
|
viyaresult=&viyaresult,
|
||||||
else do;
|
viyacontext=&viyacontext
|
||||||
x+1;
|
)
|
||||||
call symputx(name,quote(cats(value)),'l');
|
|
||||||
call symputx(cats('pval',x),name,'l');
|
|
||||||
call symputx('pcnt',x,'l');
|
|
||||||
end;
|
|
||||||
run;
|
|
||||||
%mp_abort(iftrue= (%mf_nobs(&inputparams) ne &pcnt)
|
|
||||||
,mac=&sysmacroname
|
|
||||||
,msg=%str(Invalid values in &inputparams)
|
|
||||||
)
|
|
||||||
%end;
|
|
||||||
|
|
||||||
/* convert inputdatasets to filerefs */
|
%mend mp_testservice;
|
||||||
%if "&inputdatasets" ne "0" %then %do;
|
|
||||||
%if %quote(&inputfiles)=0 %then %let inputfiles=;
|
|
||||||
%do i=1 %to %sysfunc(countw(&inputdatasets,%str( )));
|
|
||||||
%let var=%scan(&inputdatasets,&i,%str( ));
|
|
||||||
%local dsref&i;
|
|
||||||
%let dsref&i=%mf_getuniquefileref();
|
|
||||||
%mp_ds2csv(&var,outref=&&dsref&i,headerformat=SASJS)
|
|
||||||
%let inputfiles=&inputfiles &&dsref&i:%scan(&var,-1,.);
|
|
||||||
%end;
|
|
||||||
%end;
|
|
||||||
|
|
||||||
%let platform=%mf_getplatform();
|
|
||||||
%let fref1=%mf_getuniquefileref();
|
|
||||||
%let fref2=%mf_getuniquefileref();
|
|
||||||
%let webref=%mf_getuniquefileref();
|
|
||||||
%let webrefpath=%sysfunc(pathname(work))/%mf_getuniquename();
|
|
||||||
/* mp_chop requires a physical path as input */
|
|
||||||
filename &webref "&webrefpath";
|
|
||||||
|
|
||||||
%if &platform=SASMETA %then %do;
|
|
||||||
|
|
||||||
/* parse the input files */
|
|
||||||
%if %quote(&inputfiles) ne 0 %then %do;
|
|
||||||
%let webcount=%sysfunc(countw(&inputfiles));
|
|
||||||
%put &=webcount;
|
|
||||||
%do i=1 %to &webcount;
|
|
||||||
%let var=%scan(&inputfiles,&i,%str( ));
|
|
||||||
%local webfref&i webname&i;
|
|
||||||
%let webref&i=%scan(&var,1,%str(:));
|
|
||||||
%let webname&i=%scan(&var,2,%str(:));
|
|
||||||
%put webref&i=&&webref&i;
|
|
||||||
%put webname&i=&&webname&i;
|
|
||||||
%end;
|
|
||||||
%end;
|
|
||||||
%else %let webcount=0;
|
|
||||||
|
|
||||||
proc stp program="&program";
|
|
||||||
inputparam _program="&program"
|
|
||||||
%do i=1 %to &webcount;
|
|
||||||
%if &webcount=1 %then %do;
|
|
||||||
_webin_fileref="&&webref&i"
|
|
||||||
_webin_name="&&webname&i"
|
|
||||||
%end;
|
|
||||||
%else %do;
|
|
||||||
_webin_fileref&i="&&webref&i"
|
|
||||||
_webin_name&i="&&webname&i"
|
|
||||||
%end;
|
|
||||||
%end;
|
|
||||||
_webin_file_count="&webcount"
|
|
||||||
_debug="&debug"
|
|
||||||
%do i=1 %to &pcnt;
|
|
||||||
/* resolve name only, proc stp fetches value */
|
|
||||||
&&pval&i=&&&&&&pval&i
|
|
||||||
%end;
|
|
||||||
;
|
|
||||||
%do i=1 %to &webcount;
|
|
||||||
inputfile &&webref&i;
|
|
||||||
%end;
|
|
||||||
outputfile _webout=&webref;
|
|
||||||
run;
|
|
||||||
|
|
||||||
data _null_;
|
|
||||||
infile &webref;
|
|
||||||
file &fref1;
|
|
||||||
input;
|
|
||||||
length line $10000;
|
|
||||||
if index(_infile_,'>>weboutBEGIN<<') then do;
|
|
||||||
line=tranwrd(_infile_,'>>weboutBEGIN<<','');
|
|
||||||
put line;
|
|
||||||
end;
|
|
||||||
else if index(_infile_,'>>weboutEND<<') then do;
|
|
||||||
line=tranwrd(_infile_,'>>weboutEND<<','');
|
|
||||||
put line;
|
|
||||||
stop;
|
|
||||||
end;
|
|
||||||
else put _infile_;
|
|
||||||
run;
|
|
||||||
data _null_;
|
|
||||||
infile &fref1;
|
|
||||||
input;
|
|
||||||
put _infile_;
|
|
||||||
run;
|
|
||||||
%if &outlib ne 0 %then %do;
|
|
||||||
libname &outlib json (&fref1);
|
|
||||||
%end;
|
|
||||||
%if &outref ne 0 %then %do;
|
|
||||||
filename &outref temp;
|
|
||||||
%mp_binarycopy(inref=&webref,outref=&outref)
|
|
||||||
%end;
|
|
||||||
|
|
||||||
%end;
|
|
||||||
%else %if &platform=SASVIYA %then %do;
|
|
||||||
|
|
||||||
/* prepare inputparams */
|
|
||||||
%local ds1;
|
|
||||||
%let ds1=%mf_getuniquename();
|
|
||||||
%if "&inputparams" ne "0" %then %do;
|
|
||||||
proc transpose data=&inputparams out=&ds1;
|
|
||||||
id name;
|
|
||||||
var value;
|
|
||||||
run;
|
|
||||||
%end;
|
|
||||||
%else %do;
|
|
||||||
data &ds1;run;
|
|
||||||
%end;
|
|
||||||
|
|
||||||
/* parse the input files - convert to sasjs params */
|
|
||||||
%local webcount i var sasjs_tables;
|
|
||||||
%if %quote(&inputfiles) ne 0 %then %do;
|
|
||||||
%let webcount=%sysfunc(countw(&inputfiles));
|
|
||||||
%put &=webcount;
|
|
||||||
%do i=1 %to &webcount;
|
|
||||||
%let var=%scan(&inputfiles,&i,%str( ));
|
|
||||||
%local webfref&i webname&i sasjs&i.data;
|
|
||||||
%let webref&i=%scan(&var,1,%str(:));
|
|
||||||
%let webname&i=%scan(&var,2,%str(:));
|
|
||||||
%put webref&i=&&webref&i;
|
|
||||||
%put webname&i=&&webname&i;
|
|
||||||
|
|
||||||
%let sasjs_tables=&sasjs_tables &&webname&i;
|
|
||||||
data _null_;
|
|
||||||
infile &&webref&i lrecl=32767;
|
|
||||||
input;
|
|
||||||
if _n_=1 then call symputx("sasjs&i.data",_infile_);
|
|
||||||
else call symputx(
|
|
||||||
"sasjs&i.data",cats(symget("sasjs&i.data"),'0D0A'x,_infile_)
|
|
||||||
);
|
|
||||||
putlog "&sysmacroname infile: " _infile_;
|
|
||||||
run;
|
|
||||||
data &ds1;
|
|
||||||
set &ds1;
|
|
||||||
length sasjs&i.data $32767 sasjs_tables $1000;
|
|
||||||
sasjs&i.data=symget("sasjs&i.data");
|
|
||||||
sasjs_tables=symget("sasjs_tables");
|
|
||||||
run;
|
|
||||||
%end;
|
|
||||||
%end;
|
|
||||||
%else %let webcount=0;
|
|
||||||
|
|
||||||
data &ds1;
|
|
||||||
retain _program "&program";
|
|
||||||
retain _contextname "&viyacontext";
|
|
||||||
set &ds1;
|
|
||||||
putlog "&sysmacroname inputparams:";
|
|
||||||
putlog (_all_)(=);
|
|
||||||
run;
|
|
||||||
|
|
||||||
%mv_jobflow(inds=&ds1
|
|
||||||
,maxconcurrency=1
|
|
||||||
,outds=work.results
|
|
||||||
,outref=&fref1
|
|
||||||
,mdebug=&mdebug
|
|
||||||
)
|
|
||||||
/* show the log */
|
|
||||||
data _null_;
|
|
||||||
infile &fref1;
|
|
||||||
input;
|
|
||||||
putlog _infile_;
|
|
||||||
run;
|
|
||||||
/* get the uri to fetch results */
|
|
||||||
data _null_;
|
|
||||||
set work.results;
|
|
||||||
call symputx('uri',uri);
|
|
||||||
putlog "&sysmacroname: fetching results for " uri;
|
|
||||||
run;
|
|
||||||
/* fetch results from webout.json */
|
|
||||||
%mv_getjobresult(uri=&uri,
|
|
||||||
result=&viyaresult,
|
|
||||||
outref=&outref,
|
|
||||||
outlib=&outlib,
|
|
||||||
mdebug=&mdebug
|
|
||||||
)
|
|
||||||
|
|
||||||
%end;
|
|
||||||
%else %if &platform=SASJS %then %do;
|
|
||||||
|
|
||||||
%ms_testservice(&program
|
|
||||||
,inputfiles=&inputfiles
|
|
||||||
,inputdatasets=&inputdatasets
|
|
||||||
,inputparams=&inputparams
|
|
||||||
,debug=&debug
|
|
||||||
,mdebug=&mdebug
|
|
||||||
,outlib=&outlib
|
|
||||||
,outref=&outref
|
|
||||||
)
|
|
||||||
|
|
||||||
%end;
|
|
||||||
%else %do;
|
|
||||||
%put %str(ERR)OR: Unrecognised platform: &platform;
|
|
||||||
%end;
|
|
||||||
|
|
||||||
%if &mdebug=0 %then %do;
|
|
||||||
filename &fref1 clear;
|
|
||||||
%if &platform ne SASJS %then %do;
|
|
||||||
filename &fref2 clear;
|
|
||||||
filename &webref clear;
|
|
||||||
%end;
|
|
||||||
%end;
|
|
||||||
%else %do;
|
|
||||||
%put &sysmacroname exit vars:;
|
|
||||||
%put _local_;
|
|
||||||
%end;
|
|
||||||
|
|
||||||
%mend mp_testservice;
|
|
||||||
|
|||||||
2
build.py
2
build.py
@@ -102,7 +102,7 @@ options noquotelenmax;
|
|||||||
"""
|
"""
|
||||||
f = open('all.sas', "w") # r / r+ / rb / rb+ / w / wb
|
f = open('all.sas', "w") # r / r+ / rb / rb+ / w / wb
|
||||||
f.write(header)
|
f.write(header)
|
||||||
folders = ['base', 'ddl', 'meta', 'metax', 'server', 'viya', 'lua', 'fcmp']
|
folders = ['base', 'ddl', 'meta', 'metax', 'server', 'viya', 'lua', 'fcmp', 'xplatform']
|
||||||
for folder in folders:
|
for folder in folders:
|
||||||
filenames = [fn for fn in Path(
|
filenames = [fn for fn in Path(
|
||||||
'./' + folder).iterdir() if fn.match("*.sas")]
|
'./' + folder).iterdir() if fn.match("*.sas")]
|
||||||
|
|||||||
48
main.dox
48
main.dox
@@ -18,7 +18,17 @@
|
|||||||
statements. Those starting `mp_` are macro _procedures_, which generate
|
statements. Those starting `mp_` are macro _procedures_, which generate
|
||||||
SAS statements, and must therefore be applied accordingly.
|
SAS statements, and must therefore be applied accordingly.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*! \dir ddl
|
||||||
|
* \brief Data Definition Language files
|
||||||
|
* \details Provides templates for commonly used tables in sasjs/core.
|
||||||
|
Attributes:
|
||||||
|
|
||||||
|
* OS independent
|
||||||
|
* No X command
|
||||||
|
* Prefixes: _mddl_
|
||||||
|
*/
|
||||||
|
|
||||||
/*! \dir fcmp
|
/*! \dir fcmp
|
||||||
* \brief Macros for generating FCMP functions
|
* \brief Macros for generating FCMP functions
|
||||||
@@ -94,13 +104,37 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*! \dir ddl
|
/*! \dir tests/base
|
||||||
* \brief Data Definition Language files
|
* \brief Tests for Base macros
|
||||||
* \details Provides templates for commonly used tables in sasjs/core.
|
*/
|
||||||
Attributes:
|
|
||||||
|
/*! \dir tests/ddlonly
|
||||||
|
* \brief Tests for DDL macros
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \dir tests/sas9only
|
||||||
|
* \brief Tests for SAS Metadata macros
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \dir tests/serveronly
|
||||||
|
* \brief Tests for SASjs Server macros
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \dir tests/viyaonly
|
||||||
|
* \brief Tests for Viya macros
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \dir tests/x-platform
|
||||||
|
* \brief Tests for cross-platform macros
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \dir xplatform
|
||||||
|
* \brief Cross Platform, works on all SAS servers (Viya, EBI, SASjs)
|
||||||
|
* \details Useful when you need to run a single piece of code against Viya,
|
||||||
|
SAS 9 with metadata, or SASjs on Base SAS.
|
||||||
|
|
||||||
* OS independent
|
* OS independent
|
||||||
* No X command
|
* No X command
|
||||||
* Prefixes: _mddl_
|
* Prefixes: _mx_
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,7 +2,10 @@
|
|||||||
@file mm_adduser2group.sas
|
@file mm_adduser2group.sas
|
||||||
@brief Adds a user to a group
|
@brief Adds a user to a group
|
||||||
@details Adds a user to a metadata group. The macro first checks whether the
|
@details Adds a user to a metadata group. The macro first checks whether the
|
||||||
user is in that group, and if not, the user is added.
|
user is in that group, and if not, the user is added.
|
||||||
|
|
||||||
|
Note that the macro does not check inherited group memberships - it looks at
|
||||||
|
direct members only.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
@@ -12,10 +15,10 @@
|
|||||||
|
|
||||||
@param user= the user name (not displayname)
|
@param user= the user name (not displayname)
|
||||||
@param group= the group to which to add the user
|
@param group= the group to which to add the user
|
||||||
@param mdebug= set to 1 to show debug info in log
|
@param mdebug= (0) set to 1 to show debug info in log
|
||||||
|
|
||||||
@warning the macro does not check inherited group memberships - it looks at
|
<h4> Related Files </h4>
|
||||||
direct members only
|
@li ms_adduser2group.sas
|
||||||
|
|
||||||
@version 9.3
|
@version 9.3
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
|
|||||||
@@ -1,22 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
@file mm_createdataset.sas
|
@file
|
||||||
@brief Create a dataset from a metadata definition
|
@brief Create an empty dataset from a metadata definition
|
||||||
@details This macro was built to support viewing empty tables in
|
@details This macro was built to support viewing empty tables in
|
||||||
https://datacontroller.io - a free evaluation copy is available by
|
https://datacontroller.io
|
||||||
contacting the author (Allan Bowe).
|
|
||||||
|
|
||||||
The table can be retrieved using LIBRARY.DATASET reference, or directly
|
The table can be retrieved using LIBRARY.DATASET reference, or directly
|
||||||
using the metadata URI.
|
using the metadata URI.
|
||||||
|
|
||||||
The dataset is written to the WORK library.
|
The dataset is written to the WORK library.
|
||||||
|
|
||||||
usage:
|
Usage:
|
||||||
|
|
||||||
%mm_createdataset(libds=metlib.some_dataset)
|
%mm_createdataset(libds=metlib.some_dataset)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
%mm_createdataset(tableuri=G5X8AFW1.BE00015Y)
|
%mm_createdataset(tableuri=G5X8AFW1.BE00015Y)
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mm_getlibs.sas
|
@li mm_getlibs.sas
|
||||||
@@ -26,9 +25,9 @@
|
|||||||
@param libds= library.dataset metadata source. Note - table names in metadata
|
@param libds= library.dataset metadata source. Note - table names in metadata
|
||||||
can be longer than 32 chars (just fyi, not an issue here)
|
can be longer than 32 chars (just fyi, not an issue here)
|
||||||
@param tableuri= Metadata URI of the table to be created
|
@param tableuri= Metadata URI of the table to be created
|
||||||
@param outds= The dataset to create, default is `work.mm_createdataset`.
|
@param outds= (work.mm_createdataset) The dataset to create. The table name
|
||||||
The table name needs to be 32 chars or less as per SAS naming rules.
|
needs to be 32 chars or less as per SAS naming rules.
|
||||||
@param mdebug= set DBG to 1 to disable DEBUG messages
|
@param mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
|
|
||||||
@version 9.4
|
@version 9.4
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
@@ -54,14 +53,23 @@
|
|||||||
%mm_gettables(uri=&liburi,outds=&tempds2)
|
%mm_gettables(uri=&liburi,outds=&tempds2)
|
||||||
data _null_;
|
data _null_;
|
||||||
set &tempds2;
|
set &tempds2;
|
||||||
if upcase(tablename)="%upcase(%scan(&libds,2,.))";
|
where upcase(tablename)="%upcase(%scan(&libds,2,.))";
|
||||||
|
&dbg putlog tableuri=;
|
||||||
call symputx('tableuri',tableuri);
|
call symputx('tableuri',tableuri);
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
data;run;%let tempds3=&syslast;
|
data;run;
|
||||||
|
%let tempds3=&syslast;
|
||||||
%mm_getcols(tableuri=&tableuri,outds=&tempds3)
|
%mm_getcols(tableuri=&tableuri,outds=&tempds3)
|
||||||
|
|
||||||
|
%if %mf_nobs(&tempds3)=0 %then %do;
|
||||||
|
%put &libds (&tableuri) has no columns defined!!;
|
||||||
|
data &outds;
|
||||||
|
run;
|
||||||
|
%return;
|
||||||
|
%end;
|
||||||
|
|
||||||
data _null_;
|
data _null_;
|
||||||
set &tempds3 end=last;
|
set &tempds3 end=last;
|
||||||
if _n_=1 then call execute('data &outds;');
|
if _n_=1 then call execute('data &outds;');
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ data _null_;
|
|||||||
put ' %do i=1 %to &numcols; ';
|
put ' %do i=1 %to &numcols; ';
|
||||||
put ' %if &i>1 %then "," ; ';
|
put ' %if &i>1 %then "," ; ';
|
||||||
put ' %if &action=OBJ %then """&&name&i"":" ; ';
|
put ' %if &action=OBJ %then """&&name&i"":" ; ';
|
||||||
put ' &&name&i ';
|
put ' "&&name&i"n /* name literal for reserved variable names */ ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
||||||
put ' /* now write the long strings to _webout 1 byte at a time */ ';
|
put ' /* now write the long strings to _webout 1 byte at a time */ ';
|
||||||
@@ -315,18 +315,19 @@ data _null_;
|
|||||||
put '%end; ';
|
put '%end; ';
|
||||||
put '%mend mp_jsonout; ';
|
put '%mend mp_jsonout; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put '%macro mf_getuser(type=META ';
|
put '%macro mf_getuser( ';
|
||||||
put ')/*/STORE SOURCE*/; ';
|
put ')/*/STORE SOURCE*/; ';
|
||||||
put ' %local user metavar; ';
|
put ' %local user; ';
|
||||||
put ' %if &type=OS %then %let metavar=_secureusername; ';
|
|
||||||
put ' %else %let metavar=_metaperson; ';
|
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' %if %symexist(SYS_COMPUTE_SESSION_OWNER) %then %let user=&SYS_COMPUTE_SESSION_OWNER; ';
|
put ' %if %symexist(_sasjs_username) %then %let user=&_sasjs_username; ';
|
||||||
put ' %else %if %symexist(&metavar) %then %do; ';
|
put ' %else %if %symexist(SYS_COMPUTE_SESSION_OWNER) %then %do; ';
|
||||||
put ' %if %length(&&&metavar)=0 %then %let user=&sysuserid; ';
|
put ' %let user=&SYS_COMPUTE_SESSION_OWNER; ';
|
||||||
|
put ' %end; ';
|
||||||
|
put ' %else %if %symexist(_metaperson) %then %do; ';
|
||||||
|
put ' %if %length(&_metaperson)=0 %then %let user=&sysuserid; ';
|
||||||
put ' /* sometimes SAS will add @domain extension - remove for consistency */ ';
|
put ' /* sometimes SAS will add @domain extension - remove for consistency */ ';
|
||||||
put ' /* but be sure to quote in case of usernames with commas */ ';
|
put ' /* but be sure to quote in case of usernames with commas */ ';
|
||||||
put ' %else %let user=%unquote(%scan(%quote(&&&metavar),1,@)); ';
|
put ' %else %let user=%unquote(%scan(%quote(&_metaperson),1,@)); ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' %else %let user=&sysuserid; ';
|
put ' %else %let user=&sysuserid; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
|
|||||||
@@ -8,17 +8,15 @@
|
|||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
options ps=max nonotes nosource;
|
options ps=max nonotes nosource;
|
||||||
%mm_getfoldertree(root=/My/Meta/Path, outds=iwantthisdataset)
|
%mm_getfoldertree(root=/My/Meta/Path, outds=iwantthisdataset)
|
||||||
options notes source;
|
options notes source;
|
||||||
|
|
||||||
@param [in] root= the parent folder under which to return all contents
|
@param [in] root= the parent folder under which to return all contents
|
||||||
@param [out] outds= the dataset to create that contains the list of
|
@param [out] outds= the dataset to create that contains the list of
|
||||||
directories
|
directories
|
||||||
@param [in] mDebug= set to 1 to show debug messages in the log
|
@param [in] mDebug= set to 1 to show debug messages in the log
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
|
||||||
|
|
||||||
@version 9.4
|
@version 9.4
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_getuniquefileref.sas
|
@li mf_getuniquefileref.sas
|
||||||
|
@li mp_abort.sas
|
||||||
|
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
|
|
||||||
@@ -70,11 +71,10 @@ data _null_;
|
|||||||
else put (_all_)(=);
|
else put (_all_)(=);
|
||||||
run;
|
run;
|
||||||
|
|
||||||
%if &tsuri=stopifempty %then %do;
|
%mp_abort(iftrue= (&tsuri=stopifempty)
|
||||||
%put %str(WARN)ING: &tree&name.(StoredProcess) not found!;
|
,mac=mm_getstpcode
|
||||||
%return;
|
,msg=%str(&tree&name.(StoredProcess) not found!)
|
||||||
%end;
|
)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Now we can extract the textstore
|
* Now we can extract the textstore
|
||||||
|
|||||||
@@ -8,17 +8,18 @@
|
|||||||
|
|
||||||
%mm_getusers()
|
%mm_getusers()
|
||||||
|
|
||||||
|
Optionally, filter for a user (useful to get the uri):
|
||||||
|
|
||||||
|
%mm_getusers(user=&_metaperson)
|
||||||
|
|
||||||
@param outds the dataset to create that contains the list of libraries
|
@param outds the dataset to create that contains the list of libraries
|
||||||
|
|
||||||
@returns outds dataset containing all users, with the following columns:
|
@returns outds dataset containing all users, with the following columns:
|
||||||
- uri
|
- uri
|
||||||
- name
|
- name
|
||||||
|
|
||||||
@warning The following filenames are created and then de-assigned:
|
@param user= (0) Set to a metadata user to filter on that user
|
||||||
|
@param outds= (work.mm_getusers) The output table to create
|
||||||
filename sxlemap clear;
|
|
||||||
filename response clear;
|
|
||||||
libname _XML_ clear;
|
|
||||||
|
|
||||||
@version 9.3
|
@version 9.3
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
@@ -26,23 +27,49 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
%macro mm_getusers(
|
%macro mm_getusers(
|
||||||
outds=work.mm_getusers
|
outds=work.mm_getusers,
|
||||||
|
user=0
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
filename response temp;
|
filename response temp;
|
||||||
proc metadata in= '<GetMetadataObjects>
|
%if %superq(user)=0 %then %do;
|
||||||
<Reposid>$METAREPOSITORY</Reposid>
|
proc metadata in= '<GetMetadataObjects>
|
||||||
<Type>Person</Type>
|
<Reposid>$METAREPOSITORY</Reposid>
|
||||||
<NS>SAS</NS>
|
<Type>Person</Type>
|
||||||
<Flags>0</Flags>
|
<NS>SAS</NS>
|
||||||
<Options>
|
<Flags>0</Flags>
|
||||||
<Templates>
|
<Options>
|
||||||
<Person Name=""/>
|
<Templates>
|
||||||
</Templates>
|
<Person Name=""/>
|
||||||
</Options>
|
</Templates>
|
||||||
</GetMetadataObjects>'
|
</Options>
|
||||||
out=response;
|
</GetMetadataObjects>'
|
||||||
run;
|
out=response;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
filename inref temp;
|
||||||
|
data _null_;
|
||||||
|
file inref;
|
||||||
|
put "<GetMetadataObjects>";
|
||||||
|
put "<Reposid>$METAREPOSITORY</Reposid>";
|
||||||
|
put "<Type>Person</Type>";
|
||||||
|
put "<NS>SAS</NS>";
|
||||||
|
put "<!-- Specify the OMI_XMLSELECT (128) flag -->";
|
||||||
|
put "<Flags>128</Flags>";
|
||||||
|
put "<Options>";
|
||||||
|
put "<Templates>";
|
||||||
|
put '<Person Name=""/>';
|
||||||
|
put "</Templates>";
|
||||||
|
length string $10000;
|
||||||
|
string=cats('<XMLSELECT search="Person[@Name=',"'&user'",']"/>');
|
||||||
|
put string;
|
||||||
|
put "</Options>";
|
||||||
|
put "</GetMetadataObjects>";
|
||||||
|
run;
|
||||||
|
proc metadata in=inref out=response;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
filename sxlemap temp;
|
filename sxlemap temp;
|
||||||
data _null_;
|
data _null_;
|
||||||
|
|||||||
@@ -6,8 +6,10 @@
|
|||||||
"fcmp",
|
"fcmp",
|
||||||
"lua",
|
"lua",
|
||||||
"server",
|
"server",
|
||||||
"tests/crossplatform",
|
"xplatform",
|
||||||
"tests/ddl"
|
"tests/base",
|
||||||
|
"tests/ddlonly",
|
||||||
|
"tests/x-platform"
|
||||||
],
|
],
|
||||||
"docConfig": {
|
"docConfig": {
|
||||||
"displayMacroCore": false,
|
"displayMacroCore": false,
|
||||||
@@ -65,7 +67,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "server",
|
"name": "server",
|
||||||
"serverUrl": "https://sas.analytium.co.uk:5007",
|
"serverUrl": "https://sas.4gl.io",
|
||||||
"serverType": "SASJS",
|
"serverType": "SASJS",
|
||||||
"httpsAgentOptions": {
|
"httpsAgentOptions": {
|
||||||
"allowInsecureRequests": false
|
"allowInsecureRequests": false
|
||||||
@@ -105,4 +107,4 @@
|
|||||||
"contextName": "SAS Job Execution compute context"
|
"contextName": "SAS Job Execution compute context"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
122
server/ms_adduser2group.sas
Normal file
122
server/ms_adduser2group.sas
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Adds a user to a group on SASjs Server
|
||||||
|
@details Adds a user to a group based on userid and groupid. Both user and
|
||||||
|
group must already exist.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
%ms_adduser2group(uid=1,gid=1)
|
||||||
|
|
||||||
|
|
||||||
|
@param [in] uid= (0) The User ID to be added
|
||||||
|
@param [in] gid= (0) The Group ID to contain the new user
|
||||||
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
|
@param [out] outds= (work.ms_adduser2group) This output dataset will contain
|
||||||
|
the new list of group members, eg:
|
||||||
|
|DISPLAYNAME:$18.|USERNAME:$10.|ID:best.|
|
||||||
|
|---|---|---|
|
||||||
|
|`Super Admin `|`secretuser `|`1`|
|
||||||
|
|`Sabir Hassan`|`sabir`|`2`|
|
||||||
|
|`Mihajlo Medjedovic `|`mihajlo `|`3`|
|
||||||
|
|`Ivor Townsend `|`ivor `|`4`|
|
||||||
|
|`New User `|`newuser `|`5`|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_getuniquefileref.sas
|
||||||
|
@li mf_getuniquelibref.sas
|
||||||
|
@li mp_abort.sas
|
||||||
|
|
||||||
|
<h4> Related Files </h4>
|
||||||
|
@li ms_creategroup.sas
|
||||||
|
@li ms_createuser.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro ms_adduser2group(uid=0
|
||||||
|
,gid=0
|
||||||
|
,outds=work.ms_adduser2group
|
||||||
|
,mdebug=0
|
||||||
|
);
|
||||||
|
|
||||||
|
%mp_abort(
|
||||||
|
iftrue=(&syscc ne 0)
|
||||||
|
,mac=ms_adduser2group.sas
|
||||||
|
,msg=%str(syscc=&syscc on macro entry)
|
||||||
|
)
|
||||||
|
|
||||||
|
%local fref0 fref1 fref2 libref optval rc msg;
|
||||||
|
%let fref0=%mf_getuniquefileref();
|
||||||
|
%let fref1=%mf_getuniquefileref();
|
||||||
|
%let libref=%mf_getuniquelibref();
|
||||||
|
|
||||||
|
/* avoid sending bom marker to API */
|
||||||
|
%let optval=%sysfunc(getoption(bomfile));
|
||||||
|
options nobomfile;
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
file &fref0 lrecl=1000;
|
||||||
|
infile "&_sasjs_tokenfile" lrecl=1000;
|
||||||
|
input;
|
||||||
|
if _n_=1 then put "accept: application/json";
|
||||||
|
put _infile_;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
%put _local_;
|
||||||
|
data _null_;
|
||||||
|
infile &fref0;
|
||||||
|
input;
|
||||||
|
put _infile_;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
proc http method='POST' headerin=&fref0 out=&fref1
|
||||||
|
url="&_sasjs_apiserverurl/SASjsApi/group/&gid/&uid";
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
debug level=1;
|
||||||
|
%end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_abort(
|
||||||
|
iftrue=(&syscc ne 0)
|
||||||
|
,mac=ms_adduser2group.sas
|
||||||
|
,msg=%str(Issue submitting query to SASjsApi/group)
|
||||||
|
)
|
||||||
|
|
||||||
|
libname &libref JSON fileref=&fref1;
|
||||||
|
|
||||||
|
data &outds;
|
||||||
|
set &libref..users;
|
||||||
|
drop ordinal_root ordinal_users;
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
putlog _all_;
|
||||||
|
%end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
|
||||||
|
%mp_abort(
|
||||||
|
iftrue=(&syscc ne 0)
|
||||||
|
,mac=ms_creategroup.sas
|
||||||
|
,msg=%str(Issue reading response JSON)
|
||||||
|
)
|
||||||
|
|
||||||
|
/* reset options */
|
||||||
|
options &optval;
|
||||||
|
|
||||||
|
%if &mdebug=0 %then %do;
|
||||||
|
filename &fref0 clear;
|
||||||
|
filename &fref1 clear;
|
||||||
|
libname &libref clear;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
data _null_;
|
||||||
|
infile &fref1;
|
||||||
|
input;
|
||||||
|
putlog _infile_;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
%mend ms_adduser2group;
|
||||||
149
server/ms_creategroup.sas
Normal file
149
server/ms_creategroup.sas
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Creates a group on SASjs Server
|
||||||
|
@details Creates a group on SASjs Server with the following attributes:
|
||||||
|
|
||||||
|
@li name
|
||||||
|
@li description
|
||||||
|
@li isActive
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
%ms_creategroup(mynewgroup)
|
||||||
|
|
||||||
|
%ms_creategroup(mynewergroup, desc=The group description)
|
||||||
|
|
||||||
|
@param [in] groupname The group name to create. No spaces or special chars.
|
||||||
|
@param [in] desc= (0) If no description provided, group name will be used.
|
||||||
|
@param [in] isactive= (true) Set to false to create an inactive group.
|
||||||
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
|
@param [out] outds= (work.ms_creategroup) This output dataset will contain the
|
||||||
|
values from the JSON response (such as the id of the new group)
|
||||||
|
|DESCRIPTION:$1.|GROUPID:best.|ISACTIVE:best.|NAME:$11.|
|
||||||
|
|---|---|---|---|
|
||||||
|
|`The group description`|`2 `|`1 `|`mynewergroup `|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_getuniquefileref.sas
|
||||||
|
@li mf_getuniquelibref.sas
|
||||||
|
@li mp_abort.sas
|
||||||
|
|
||||||
|
<h4> Related Files </h4>
|
||||||
|
@li ms_creategroup.test.sas
|
||||||
|
@li ms_getgroups.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro ms_creategroup(groupname
|
||||||
|
,desc=0
|
||||||
|
,isactive=true
|
||||||
|
,outds=work.ms_creategroup
|
||||||
|
,mdebug=0
|
||||||
|
);
|
||||||
|
|
||||||
|
%mp_abort(
|
||||||
|
iftrue=(&syscc ne 0)
|
||||||
|
,mac=ms_creategroup.sas
|
||||||
|
,msg=%str(syscc=&syscc on macro entry)
|
||||||
|
)
|
||||||
|
|
||||||
|
%local fref0 fref1 fref2 libref optval rc msg;
|
||||||
|
%let fref0=%mf_getuniquefileref();
|
||||||
|
%let fref1=%mf_getuniquefileref();
|
||||||
|
%let fref2=%mf_getuniquefileref();
|
||||||
|
%let libref=%mf_getuniquelibref();
|
||||||
|
|
||||||
|
/* avoid sending bom marker to API */
|
||||||
|
%let optval=%sysfunc(getoption(bomfile));
|
||||||
|
options nobomfile;
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
file &fref0 termstr=crlf;
|
||||||
|
name=quote(cats(symget('groupname')));
|
||||||
|
description=quote(cats(symget('desc')));
|
||||||
|
if cats(description)='"0"' then description=name;
|
||||||
|
isactive=symget('isactive');
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
putlog _all_;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
put '{'@;
|
||||||
|
put '"name":' name @;
|
||||||
|
put ',"description":' description @;
|
||||||
|
put ',"isActive":' isactive @;
|
||||||
|
put '}';
|
||||||
|
run;
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
file &fref1 lrecl=1000;
|
||||||
|
infile "&_sasjs_tokenfile" lrecl=1000;
|
||||||
|
input;
|
||||||
|
if _n_=1 then do;
|
||||||
|
put "Content-Type: application/json";
|
||||||
|
put "accept: application/json";
|
||||||
|
end;
|
||||||
|
put _infile_;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
data _null_;
|
||||||
|
infile &fref0;
|
||||||
|
input;
|
||||||
|
put _infile_;
|
||||||
|
data _null_;
|
||||||
|
infile &fref1;
|
||||||
|
input;
|
||||||
|
put _infile_;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
proc http method='POST' in=&fref0 headerin=&fref1 out=&fref2
|
||||||
|
url="&_sasjs_apiserverurl/SASjsApi/group";
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
debug level=1;
|
||||||
|
%end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_abort(
|
||||||
|
iftrue=(&syscc ne 0)
|
||||||
|
,mac=ms_creategroup.sas
|
||||||
|
,msg=%str(Issue submitting query to SASjsApi/group)
|
||||||
|
)
|
||||||
|
|
||||||
|
libname &libref JSON fileref=&fref2;
|
||||||
|
|
||||||
|
data &outds;
|
||||||
|
set &libref..root;
|
||||||
|
drop ordinal_root;
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
putlog _all_;
|
||||||
|
%end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
|
||||||
|
%mp_abort(
|
||||||
|
iftrue=(&syscc ne 0)
|
||||||
|
,mac=ms_creategroup.sas
|
||||||
|
,msg=%str(Issue reading response JSON)
|
||||||
|
)
|
||||||
|
|
||||||
|
/* reset options */
|
||||||
|
options &optval;
|
||||||
|
|
||||||
|
%if &mdebug=0 %then %do;
|
||||||
|
filename &fref0 clear;
|
||||||
|
filename &fref1 clear;
|
||||||
|
filename &fref2 clear;
|
||||||
|
libname &libref clear;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
data _null_;
|
||||||
|
infile &fref2;
|
||||||
|
input;
|
||||||
|
putlog _infile_;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
%mend ms_creategroup;
|
||||||
@@ -266,7 +266,7 @@ data _null_;
|
|||||||
put ' %do i=1 %to &numcols; ';
|
put ' %do i=1 %to &numcols; ';
|
||||||
put ' %if &i>1 %then "," ; ';
|
put ' %if &i>1 %then "," ; ';
|
||||||
put ' %if &action=OBJ %then """&&name&i"":" ; ';
|
put ' %if &action=OBJ %then """&&name&i"":" ; ';
|
||||||
put ' &&name&i ';
|
put ' "&&name&i"n /* name literal for reserved variable names */ ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
||||||
put ' /* now write the long strings to _webout 1 byte at a time */ ';
|
put ' /* now write the long strings to _webout 1 byte at a time */ ';
|
||||||
@@ -317,18 +317,19 @@ data _null_;
|
|||||||
put '%end; ';
|
put '%end; ';
|
||||||
put '%mend mp_jsonout; ';
|
put '%mend mp_jsonout; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put '%macro mf_getuser(type=META ';
|
put '%macro mf_getuser( ';
|
||||||
put ')/*/STORE SOURCE*/; ';
|
put ')/*/STORE SOURCE*/; ';
|
||||||
put ' %local user metavar; ';
|
put ' %local user; ';
|
||||||
put ' %if &type=OS %then %let metavar=_secureusername; ';
|
|
||||||
put ' %else %let metavar=_metaperson; ';
|
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' %if %symexist(SYS_COMPUTE_SESSION_OWNER) %then %let user=&SYS_COMPUTE_SESSION_OWNER; ';
|
put ' %if %symexist(_sasjs_username) %then %let user=&_sasjs_username; ';
|
||||||
put ' %else %if %symexist(&metavar) %then %do; ';
|
put ' %else %if %symexist(SYS_COMPUTE_SESSION_OWNER) %then %do; ';
|
||||||
put ' %if %length(&&&metavar)=0 %then %let user=&sysuserid; ';
|
put ' %let user=&SYS_COMPUTE_SESSION_OWNER; ';
|
||||||
|
put ' %end; ';
|
||||||
|
put ' %else %if %symexist(_metaperson) %then %do; ';
|
||||||
|
put ' %if %length(&_metaperson)=0 %then %let user=&sysuserid; ';
|
||||||
put ' /* sometimes SAS will add @domain extension - remove for consistency */ ';
|
put ' /* sometimes SAS will add @domain extension - remove for consistency */ ';
|
||||||
put ' /* but be sure to quote in case of usernames with commas */ ';
|
put ' /* but be sure to quote in case of usernames with commas */ ';
|
||||||
put ' %else %let user=%unquote(%scan(%quote(&&&metavar),1,@)); ';
|
put ' %else %let user=%unquote(%scan(%quote(&_metaperson),1,@)); ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' %else %let user=&sysuserid; ';
|
put ' %else %let user=&sysuserid; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
|
|||||||
147
server/ms_getgroups.sas
Normal file
147
server/ms_getgroups.sas
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Fetches the list of groups from SASjs Server
|
||||||
|
@details Fetches the list of groups from SASjs Server and writes them to an
|
||||||
|
output dataset. Provide a username to filter for the groups for a particular
|
||||||
|
user.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
%ms_getgroups(outds=userlist)
|
||||||
|
|
||||||
|
With filter on username:
|
||||||
|
|
||||||
|
%ms_getgroups(outds=userlist, user=James)
|
||||||
|
|
||||||
|
With filter on userid:
|
||||||
|
|
||||||
|
%ms_getgroups(outds=userlist, uid=1)
|
||||||
|
|
||||||
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
|
@param [in] user= (0) Provide the username on which to filter
|
||||||
|
@param [in] uid= (0) Provide the userid on which to filter
|
||||||
|
@param [out] outds= (work.ms_getgroups) This output dataset will contain the
|
||||||
|
list of groups. Format:
|
||||||
|
|NAME:$32.|DESCRIPTION:$64.|GROUPID:best.|
|
||||||
|
|---|---|---|
|
||||||
|
|`SomeGroup `|`A group `|`1`|
|
||||||
|
|`Another Group`|`this is a different group`|`2`|
|
||||||
|
|`admin`|`Administrators `|`3`|
|
||||||
|
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_getuniquefileref.sas
|
||||||
|
@li mf_getuniquelibref.sas
|
||||||
|
@li mp_abort.sas
|
||||||
|
|
||||||
|
<h4> Related Files </h4>
|
||||||
|
@li ms_creategroup.sas
|
||||||
|
@li ms_getgroups.test.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro ms_getgroups(
|
||||||
|
user=0,
|
||||||
|
uid=0,
|
||||||
|
outds=work.ms_getgroups,
|
||||||
|
mdebug=0
|
||||||
|
);
|
||||||
|
|
||||||
|
%mp_abort(
|
||||||
|
iftrue=(&syscc ne 0)
|
||||||
|
,mac=ms_getgroups.sas
|
||||||
|
,msg=%str(syscc=&syscc on macro entry)
|
||||||
|
)
|
||||||
|
|
||||||
|
%local fref0 fref1 libref optval rc msg url;
|
||||||
|
|
||||||
|
%if %sysget(MODE)=desktop %then %do;
|
||||||
|
/* groups api does not exist in desktop mode */
|
||||||
|
data &outds;
|
||||||
|
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
||||||
|
name="&sysuserid";
|
||||||
|
description="&sysuserid (group - desktop mode)";
|
||||||
|
groupid=1;
|
||||||
|
output;
|
||||||
|
stop;
|
||||||
|
run;
|
||||||
|
%return;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
%let fref0=%mf_getuniquefileref();
|
||||||
|
%let fref1=%mf_getuniquefileref();
|
||||||
|
%let libref=%mf_getuniquelibref();
|
||||||
|
|
||||||
|
/* avoid sending bom marker to API */
|
||||||
|
%let optval=%sysfunc(getoption(bomfile));
|
||||||
|
options nobomfile;
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
file &fref0 lrecl=1000;
|
||||||
|
infile "&_sasjs_tokenfile" lrecl=1000;
|
||||||
|
input;
|
||||||
|
if _n_=1 then put "accept: application/json";
|
||||||
|
put _infile_;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
data _null_;
|
||||||
|
infile &fref0;
|
||||||
|
input;
|
||||||
|
put _infile_;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
%if "&user" ne "0" %then %let url=/SASjsApi/user/by/username/&user;
|
||||||
|
%else %if "&uid" ne "0" %then %let url=/SASjsApi/user/&uid;
|
||||||
|
%else %let url=/SASjsApi/group;
|
||||||
|
|
||||||
|
|
||||||
|
proc http method='GET' headerin=&fref0 out=&fref1
|
||||||
|
url="&_sasjs_apiserverurl.&url";
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
debug level=1;
|
||||||
|
%end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_abort(
|
||||||
|
iftrue=(&syscc ne 0)
|
||||||
|
,mac=ms_getgroups.sas
|
||||||
|
,msg=%str(Issue submitting GET query to SASjsApi)
|
||||||
|
)
|
||||||
|
|
||||||
|
libname &libref JSON fileref=&fref1;
|
||||||
|
|
||||||
|
%if "&user"="0" and "&uid"="0" %then %do;
|
||||||
|
data &outds;
|
||||||
|
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
||||||
|
if _n_=1 then call missing(of _all_);
|
||||||
|
set &libref..root;
|
||||||
|
drop ordinal_root;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
data &outds;
|
||||||
|
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
||||||
|
if _n_=1 then call missing(of _all_);
|
||||||
|
set &libref..groups;
|
||||||
|
drop ordinal_:;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
%mp_abort(
|
||||||
|
iftrue=(&syscc ne 0)
|
||||||
|
,mac=ms_getgroups.sas
|
||||||
|
,msg=%str(Issue reading response JSON)
|
||||||
|
)
|
||||||
|
|
||||||
|
/* reset options */
|
||||||
|
options &optval;
|
||||||
|
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
filename &fref0 clear;
|
||||||
|
filename &fref1 clear;
|
||||||
|
libname &libref clear;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
%mend ms_getgroups;
|
||||||
@@ -2,16 +2,26 @@
|
|||||||
@file
|
@file
|
||||||
@brief Fetches the list of users from SASjs Server
|
@brief Fetches the list of users from SASjs Server
|
||||||
@details Fetches the list of users from SASjs Server and writes them to an
|
@details Fetches the list of users from SASjs Server and writes them to an
|
||||||
output dataset.
|
output dataset. Can also be filtered, for a particular group.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
%ms_getusers(outds=userlist)
|
%ms_getusers(outds=userlist)
|
||||||
|
|
||||||
|
Filtering for a group by group name:
|
||||||
|
|
||||||
|
%ms_getusers(outds=work.groupmembers, group=GROUPNAME)
|
||||||
|
|
||||||
|
Filtering for a group by group id:
|
||||||
|
|
||||||
|
%ms_getusers(outds=work.groupmembers, gid=1)
|
||||||
|
|
||||||
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
|
@param [in] group= (0) Set to a group name to filter members for that group
|
||||||
|
@param [in] gid= (0) Set to a group id to filter members for that group
|
||||||
@param [out] outds= (work.ms_getusers) This output dataset will contain the
|
@param [out] outds= (work.ms_getusers) This output dataset will contain the
|
||||||
list of user accounts. Format:
|
list of user accounts. Format:
|
||||||
|DISPLAYNAME:$18.|USERNAME:$10.|ID:best.|
|
|DISPLAYNAME:$60.|USERNAME:$30.|ID:best.|
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
|`Super Admin `|`secretuser `|`1`|
|
|`Super Admin `|`secretuser `|`1`|
|
||||||
|`Sabir Hassan`|`sabir`|`2`|
|
|`Sabir Hassan`|`sabir`|`2`|
|
||||||
@@ -20,7 +30,6 @@
|
|||||||
|`New User `|`newuser `|`5`|
|
|`New User `|`newuser `|`5`|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_getuniquefileref.sas
|
@li mf_getuniquefileref.sas
|
||||||
@li mf_getuniquelibref.sas
|
@li mf_getuniquelibref.sas
|
||||||
@@ -28,14 +37,17 @@
|
|||||||
|
|
||||||
<h4> Related Files </h4>
|
<h4> Related Files </h4>
|
||||||
@li ms_createuser.sas
|
@li ms_createuser.sas
|
||||||
|
@li ms_getgroups.sas
|
||||||
@li ms_getusers.test.sas
|
@li ms_getusers.test.sas
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
%macro ms_getusers(
|
%macro ms_getusers(
|
||||||
outds=work.ms_getusers
|
outds=work.ms_getusers,
|
||||||
,mdebug=0
|
group=0,
|
||||||
);
|
gid=0,
|
||||||
|
mdebug=0
|
||||||
|
);
|
||||||
|
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
@@ -43,11 +55,24 @@
|
|||||||
,msg=%str(syscc=&syscc on macro entry)
|
,msg=%str(syscc=&syscc on macro entry)
|
||||||
)
|
)
|
||||||
|
|
||||||
%local fref0 fref1 libref optval rc msg;
|
%local fref0 fref1 libref optval rc msg url;
|
||||||
%let fref0=%mf_getuniquefileref();
|
%let fref0=%mf_getuniquefileref();
|
||||||
%let fref1=%mf_getuniquefileref();
|
%let fref1=%mf_getuniquefileref();
|
||||||
%let libref=%mf_getuniquelibref();
|
%let libref=%mf_getuniquelibref();
|
||||||
|
|
||||||
|
%if %sysget(MODE)=desktop %then %do;
|
||||||
|
/* users api does not exist in desktop mode */
|
||||||
|
data &outds;
|
||||||
|
length DISPLAYNAME $60 USERNAME:$30 ID 8;
|
||||||
|
USERNAME="&sysuserid";
|
||||||
|
DISPLAYNAME="&sysuserid (desktop mode)";
|
||||||
|
ID=1;
|
||||||
|
output;
|
||||||
|
stop;
|
||||||
|
run;
|
||||||
|
%return;
|
||||||
|
%end;
|
||||||
|
|
||||||
/* avoid sending bom marker to API */
|
/* avoid sending bom marker to API */
|
||||||
%let optval=%sysfunc(getoption(bomfile));
|
%let optval=%sysfunc(getoption(bomfile));
|
||||||
options nobomfile;
|
options nobomfile;
|
||||||
@@ -68,26 +93,40 @@ run;
|
|||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
|
%if "&group" ne "0" %then %let url=/SASjsApi/group/by/groupname/&group;
|
||||||
|
%else %if "&gid" ne "0" %then %let url=/SASjsApi/group/&gid;
|
||||||
|
%else %let url=/SASjsApi/user;
|
||||||
|
|
||||||
proc http method='GET' headerin=&fref0 out=&fref1
|
proc http method='GET' headerin=&fref0 out=&fref1
|
||||||
url="&_sasjs_apiserverurl/SASjsApi/user";
|
url="&_sasjs_apiserverurl.&url";
|
||||||
%if &mdebug=1 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
debug level=1;
|
debug level=1;
|
||||||
%end;
|
%end;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
|
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
,mac=ms_getusers.sas
|
,mac=ms_getusers.sas
|
||||||
,msg=%str(Issue submitting GET query to SASjsApi/user)
|
,msg=%str(Issue submitting API query)
|
||||||
)
|
)
|
||||||
|
|
||||||
libname &libref JSON fileref=&fref1;
|
libname &libref JSON fileref=&fref1;
|
||||||
|
|
||||||
data &outds;
|
%if "&group"="0" and "&gid"="0" %then %do;
|
||||||
set &libref..root;
|
data &outds;
|
||||||
drop ordinal_root;
|
length DISPLAYNAME $60 USERNAME:$30 ID 8;
|
||||||
run;
|
set &libref..root;
|
||||||
|
drop ordinal_root;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
data &outds;
|
||||||
|
length DISPLAYNAME $60 USERNAME:$30 ID 8;
|
||||||
|
set &libref..users;
|
||||||
|
drop ordinal_root ordinal_users;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ proc http method='POST' headerin=&authref in=&mainref out=&outref
|
|||||||
%end;
|
%end;
|
||||||
run;
|
run;
|
||||||
%if (&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201)
|
%if (&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201)
|
||||||
|
or &mdebug=1
|
||||||
%then %do;
|
%then %do;
|
||||||
data _null_;infile &outref;input;putlog _infile_;run;
|
data _null_;infile &outref;input;putlog _infile_;run;
|
||||||
%end;
|
%end;
|
||||||
@@ -177,7 +178,7 @@ options &optval;
|
|||||||
%if &outlogds ne _null_ or &mdebug=1 %then %do;
|
%if &outlogds ne _null_ or &mdebug=1 %then %do;
|
||||||
%local dumplib;
|
%local dumplib;
|
||||||
%let dumplib=%mf_getuniquelibref();
|
%let dumplib=%mf_getuniquelibref();
|
||||||
libname &dumplib json (&outref);
|
libname &dumplib json fileref=&outref;
|
||||||
data &outlogds;
|
data &outlogds;
|
||||||
set &dumplib..log;
|
set &dumplib..log;
|
||||||
%if &mdebug=1 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
@@ -195,4 +196,4 @@ options &optval;
|
|||||||
filename &authref;
|
filename &authref;
|
||||||
filename &mainref;
|
filename &mainref;
|
||||||
%end;
|
%end;
|
||||||
%mend ms_runstp;
|
%mend ms_runstp;
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
%mf_mkdir(&root/a/d)
|
%mf_mkdir(&root/a/d)
|
||||||
%mf_mkdir(&root/a/e)
|
%mf_mkdir(&root/a/e)
|
||||||
%mf_mkdir(&root/a/e/f)
|
%mf_mkdir(&root/a/e/f)
|
||||||
data "&root/a/e/f/ds1.sas7bdat";
|
libname test "&root/a/e/f";
|
||||||
|
data test.ds1;
|
||||||
x=1;
|
x=1;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user