mirror of
https://github.com/sasjs/core.git
synced 2026-01-05 00:20:05 +00:00
Compare commits
38 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 |
582
all.sas
582
all.sas
@@ -324,9 +324,6 @@ https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/baseplus.md#functionex
|
|||||||
|
|
||||||
%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
|
||||||
|
|
||||||
@@ -1144,18 +1141,19 @@ or %index(&pgm,/tests/testteardown)
|
|||||||
@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;
|
||||||
|
|
||||||
@@ -2200,16 +2198,20 @@ Usage:
|
|||||||
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
|
||||||
@@ -2230,11 +2232,12 @@ Usage:
|
|||||||
@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
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@@ -2243,7 +2246,8 @@ Usage:
|
|||||||
, 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;
|
||||||
|
|
||||||
@@ -2253,7 +2257,7 @@ Usage:
|
|||||||
|
|
||||||
%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;
|
||||||
@@ -2269,9 +2273,9 @@ Usage:
|
|||||||
%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;
|
||||||
@@ -2337,8 +2341,8 @@ Usage:
|
|||||||
%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;
|
||||||
@@ -2347,11 +2351,24 @@ Usage:
|
|||||||
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;
|
||||||
@@ -2367,7 +2384,8 @@ Usage:
|
|||||||
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" : [{';
|
||||||
@@ -2399,8 +2417,8 @@ Usage:
|
|||||||
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_;
|
||||||
@@ -2411,22 +2429,30 @@ Usage:
|
|||||||
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 */
|
||||||
@@ -8787,7 +8813,7 @@ options
|
|||||||
%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 */
|
||||||
@@ -12990,7 +13016,10 @@ create table &libds(
|
|||||||
@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:
|
||||||
|
|
||||||
@@ -13000,10 +13029,10 @@ create table &libds(
|
|||||||
|
|
||||||
@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
|
||||||
@@ -13801,24 +13830,23 @@ run;
|
|||||||
|
|
||||||
|
|
||||||
%mend mm_createapplication;/**
|
%mend mm_createapplication;/**
|
||||||
@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
|
||||||
@@ -13828,9 +13856,9 @@ run;
|
|||||||
@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
|
||||||
@@ -13856,14 +13884,23 @@ run;
|
|||||||
%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;');
|
||||||
@@ -15156,7 +15193,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 */ ';
|
||||||
@@ -15207,18 +15244,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 ' ';
|
||||||
@@ -16206,17 +16244,15 @@ filename __outdoc clear;
|
|||||||
|
|
||||||
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
|
||||||
|
|
||||||
@@ -17155,6 +17191,7 @@ filename __mc2 clear;
|
|||||||
|
|
||||||
<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
|
||||||
|
|
||||||
@@ -17204,11 +17241,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
|
||||||
@@ -17747,17 +17783,18 @@ libname _XML_ clear;
|
|||||||
|
|
||||||
%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
|
||||||
@@ -17765,23 +17802,49 @@ libname _XML_ clear;
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
%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_;
|
||||||
@@ -19070,6 +19133,128 @@ run;
|
|||||||
%let rc=%sysfunc(filename(&fref));
|
%let rc=%sysfunc(filename(&fref));
|
||||||
|
|
||||||
%mend mfs_httpheader;
|
%mend mfs_httpheader;
|
||||||
|
/**
|
||||||
|
@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;
|
||||||
/**
|
/**
|
||||||
@file
|
@file
|
||||||
@brief Creates a file on SASjs Drive
|
@brief Creates a file on SASjs Drive
|
||||||
@@ -19745,7 +19930,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 */ ';
|
||||||
@@ -19796,18 +19981,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 ' ';
|
||||||
@@ -20115,13 +20301,24 @@ filename &headref clear;
|
|||||||
@file
|
@file
|
||||||
@brief Fetches the list of groups from SASjs Server
|
@brief Fetches the list of groups from SASjs Server
|
||||||
@details Fetches the list of groups from SASjs Server and writes them to an
|
@details Fetches the list of groups from SASjs Server and writes them to an
|
||||||
output dataset.
|
output dataset. Provide a username to filter for the groups for a particular
|
||||||
|
user.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
%ms_getgroups(outds=userlist)
|
%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] 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
|
@param [out] outds= (work.ms_getgroups) This output dataset will contain the
|
||||||
list of groups. Format:
|
list of groups. Format:
|
||||||
|NAME:$32.|DESCRIPTION:$64.|GROUPID:best.|
|
|NAME:$32.|DESCRIPTION:$64.|GROUPID:best.|
|
||||||
@@ -20138,22 +20335,38 @@ filename &headref clear;
|
|||||||
|
|
||||||
<h4> Related Files </h4>
|
<h4> Related Files </h4>
|
||||||
@li ms_creategroup.sas
|
@li ms_creategroup.sas
|
||||||
@li ms_getusers.test.sas
|
@li ms_getgroups.test.sas
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
%macro ms_getgroups(
|
%macro ms_getgroups(
|
||||||
outds=work.ms_getgroups
|
user=0,
|
||||||
,mdebug=0
|
uid=0,
|
||||||
);
|
outds=work.ms_getgroups,
|
||||||
|
mdebug=0
|
||||||
|
);
|
||||||
|
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
,mac=ms_getusers.sas
|
,mac=ms_getgroups.sas
|
||||||
,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;
|
||||||
|
|
||||||
|
%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 fref0=%mf_getuniquefileref();
|
||||||
%let fref1=%mf_getuniquefileref();
|
%let fref1=%mf_getuniquefileref();
|
||||||
%let libref=%mf_getuniquelibref();
|
%let libref=%mf_getuniquelibref();
|
||||||
@@ -20178,8 +20391,13 @@ run;
|
|||||||
run;
|
run;
|
||||||
%end;
|
%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
|
proc http method='GET' headerin=&fref0 out=&fref1
|
||||||
url="&_sasjs_apiserverurl/SASjsApi/group";
|
url="&_sasjs_apiserverurl.&url";
|
||||||
%if &mdebug=1 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
debug level=1;
|
debug level=1;
|
||||||
%end;
|
%end;
|
||||||
@@ -20188,21 +20406,31 @@ run;
|
|||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
,mac=ms_getgroups.sas
|
,mac=ms_getgroups.sas
|
||||||
,msg=%str(Issue submitting GET query to SASjsApi/group)
|
,msg=%str(Issue submitting GET query to SASjsApi)
|
||||||
)
|
)
|
||||||
|
|
||||||
libname &libref JSON fileref=&fref1;
|
libname &libref JSON fileref=&fref1;
|
||||||
|
|
||||||
data &outds;
|
%if "&user"="0" and "&uid"="0" %then %do;
|
||||||
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
data &outds;
|
||||||
if _n_=1 then call missing(of _all_);
|
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
||||||
set &libref..root;
|
if _n_=1 then call missing(of _all_);
|
||||||
drop ordinal_root;
|
set &libref..root;
|
||||||
run;
|
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(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
,mac=ms_getusers.sas
|
,mac=ms_getgroups.sas
|
||||||
,msg=%str(Issue reading response JSON)
|
,msg=%str(Issue reading response JSON)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -20220,16 +20448,26 @@ options &optval;
|
|||||||
@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`|
|
||||||
@@ -20238,7 +20476,6 @@ options &optval;
|
|||||||
|`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
|
||||||
@@ -20246,14 +20483,17 @@ options &optval;
|
|||||||
|
|
||||||
<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)
|
||||||
@@ -20261,11 +20501,24 @@ options &optval;
|
|||||||
,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;
|
||||||
@@ -20286,26 +20539,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)
|
||||||
@@ -22006,7 +22273,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 */ ';
|
||||||
@@ -22057,18 +22324,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 ' ';
|
||||||
@@ -26841,7 +27109,8 @@ endsub;
|
|||||||
@file mx_createwebservice.sas
|
@file mx_createwebservice.sas
|
||||||
@brief Create a web service in SAS 9, Viya or SASjs
|
@brief Create a web service in SAS 9, Viya or SASjs
|
||||||
@details Creates a SASJS ready Stored Process in SAS 9, a Job Execution
|
@details Creates a SASJS ready Stored Process in SAS 9, a Job Execution
|
||||||
Service in SAS Viya, and a Stored Program on SASjs Server
|
Service in SAS Viya, or a Stored Program on SASjs Server - depending on the
|
||||||
|
executing environment.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
@@ -26863,7 +27132,9 @@ Usage:
|
|||||||
%webout(OBJ,example2) * Object format, easier to work with ;
|
%webout(OBJ,example2) * Object format, easier to work with ;
|
||||||
%webout(CLOSE)
|
%webout(CLOSE)
|
||||||
;;;;
|
;;;;
|
||||||
%mp_createwebservice(path=/Public/app/common,name=appInit,replace=YES)
|
|
||||||
|
%* create the service (including webout macro and dependencies);
|
||||||
|
%mx_createwebservice(path=/Public/app/common,name=appInit,replace=YES)
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_getplatform.sas
|
@li mf_getplatform.sas
|
||||||
@@ -26882,7 +27153,6 @@ Usage:
|
|||||||
location
|
location
|
||||||
@param [in] mDebug= (0) set to 1 to show debug messages in the log
|
@param [in] mDebug= (0) set to 1 to show debug messages in the log
|
||||||
|
|
||||||
@version 9.2
|
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@@ -26950,7 +27220,7 @@ Usage:
|
|||||||
@param [out] outref= (0) The fileref to create, which will contain the source
|
@param [out] outref= (0) The fileref to create, which will contain the source
|
||||||
code.
|
code.
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_getplatform.sas
|
@li mf_getplatform.sas
|
||||||
@li mm_getstpcode.sas
|
@li mm_getstpcode.sas
|
||||||
@li ms_getfile.sas
|
@li ms_getfile.sas
|
||||||
@@ -26969,8 +27239,8 @@ Usage:
|
|||||||
%if &platform=SASJS %then %do;
|
%if &platform=SASJS %then %do;
|
||||||
%ms_getfile(&loc..sas, outref=&outref)
|
%ms_getfile(&loc..sas, outref=&outref)
|
||||||
%end;
|
%end;
|
||||||
%else %if &platform=SAS9 %then %do;
|
%else %if &platform=SAS9 or &platform=SASMETA %then %do;
|
||||||
%mm_getstpcode(tree=&loc,outloc=&outref)
|
%mm_getstpcode(tree=&loc,outref=&outref)
|
||||||
%end;
|
%end;
|
||||||
%else %if &platform=SASVIYA %then %do;
|
%else %if &platform=SASVIYA %then %do;
|
||||||
/* extract name & path from &loc */
|
/* extract name & path from &loc */
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -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 */
|
||||||
|
|||||||
@@ -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 */
|
||||||
|
|||||||
@@ -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_;
|
||||||
|
|||||||
@@ -67,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
|
||||||
@@ -107,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;
|
||||||
@@ -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 ' ';
|
||||||
|
|||||||
@@ -2,13 +2,24 @@
|
|||||||
@file
|
@file
|
||||||
@brief Fetches the list of groups from SASjs Server
|
@brief Fetches the list of groups from SASjs Server
|
||||||
@details Fetches the list of groups from SASjs Server and writes them to an
|
@details Fetches the list of groups from SASjs Server and writes them to an
|
||||||
output dataset.
|
output dataset. Provide a username to filter for the groups for a particular
|
||||||
|
user.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
%ms_getgroups(outds=userlist)
|
%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] 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
|
@param [out] outds= (work.ms_getgroups) This output dataset will contain the
|
||||||
list of groups. Format:
|
list of groups. Format:
|
||||||
|NAME:$32.|DESCRIPTION:$64.|GROUPID:best.|
|
|NAME:$32.|DESCRIPTION:$64.|GROUPID:best.|
|
||||||
@@ -25,22 +36,38 @@
|
|||||||
|
|
||||||
<h4> Related Files </h4>
|
<h4> Related Files </h4>
|
||||||
@li ms_creategroup.sas
|
@li ms_creategroup.sas
|
||||||
@li ms_getusers.test.sas
|
@li ms_getgroups.test.sas
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
%macro ms_getgroups(
|
%macro ms_getgroups(
|
||||||
outds=work.ms_getgroups
|
user=0,
|
||||||
,mdebug=0
|
uid=0,
|
||||||
);
|
outds=work.ms_getgroups,
|
||||||
|
mdebug=0
|
||||||
|
);
|
||||||
|
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
,mac=ms_getusers.sas
|
,mac=ms_getgroups.sas
|
||||||
,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;
|
||||||
|
|
||||||
|
%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 fref0=%mf_getuniquefileref();
|
||||||
%let fref1=%mf_getuniquefileref();
|
%let fref1=%mf_getuniquefileref();
|
||||||
%let libref=%mf_getuniquelibref();
|
%let libref=%mf_getuniquelibref();
|
||||||
@@ -65,8 +92,13 @@ run;
|
|||||||
run;
|
run;
|
||||||
%end;
|
%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
|
proc http method='GET' headerin=&fref0 out=&fref1
|
||||||
url="&_sasjs_apiserverurl/SASjsApi/group";
|
url="&_sasjs_apiserverurl.&url";
|
||||||
%if &mdebug=1 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
debug level=1;
|
debug level=1;
|
||||||
%end;
|
%end;
|
||||||
@@ -75,21 +107,31 @@ run;
|
|||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
,mac=ms_getgroups.sas
|
,mac=ms_getgroups.sas
|
||||||
,msg=%str(Issue submitting GET query to SASjsApi/group)
|
,msg=%str(Issue submitting GET query to SASjsApi)
|
||||||
)
|
)
|
||||||
|
|
||||||
libname &libref JSON fileref=&fref1;
|
libname &libref JSON fileref=&fref1;
|
||||||
|
|
||||||
data &outds;
|
%if "&user"="0" and "&uid"="0" %then %do;
|
||||||
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
data &outds;
|
||||||
if _n_=1 then call missing(of _all_);
|
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
||||||
set &libref..root;
|
if _n_=1 then call missing(of _all_);
|
||||||
drop ordinal_root;
|
set &libref..root;
|
||||||
run;
|
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(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
,mac=ms_getusers.sas
|
,mac=ms_getgroups.sas
|
||||||
,msg=%str(Issue reading response JSON)
|
,msg=%str(Issue reading response JSON)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
52
tests/serveronly/ms_adduser2group.test.sas
Normal file
52
tests/serveronly/ms_adduser2group.test.sas
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Testing ms_adduser2group.sas macro
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_getuniquename.sas
|
||||||
|
@li mp_assert.sas
|
||||||
|
@li mp_assertscope.sas
|
||||||
|
@li ms_adduser2group.sas
|
||||||
|
@li ms_creategroup.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
/* first, create an empty group */
|
||||||
|
%let group=%substr(%mf_getuniquename(),1,8);
|
||||||
|
%ms_creategroup(&group, desc=The description,mdebug=&sasjs_mdebug,outds=test1a)
|
||||||
|
%let groupid=0;
|
||||||
|
data _null_;
|
||||||
|
set work.test1a;
|
||||||
|
call symputx('groupid',groupid);
|
||||||
|
run;
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(&groupid>0),
|
||||||
|
desc=Checking that group was created with an ID,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
/* now add a user (user 1 always exists) */
|
||||||
|
|
||||||
|
|
||||||
|
%mp_assertscope(SNAPSHOT)
|
||||||
|
%ms_adduser2group(uid=1,gid=&groupid,mdebug=&sasjs_mdebug,outds=test1)
|
||||||
|
%mp_assertscope(COMPARE
|
||||||
|
,ignorelist=MCLIB0_JADP1LEN MCLIB0_JADPNUM MCLIB0_JADVLEN
|
||||||
|
)
|
||||||
|
|
||||||
|
/* check the user is in the output list */
|
||||||
|
%let checkid=0;
|
||||||
|
data _null_;
|
||||||
|
set work.test1;
|
||||||
|
if id=1 then call symputx('checkid',1);
|
||||||
|
run;
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(&checkid=1),
|
||||||
|
desc=Checking that user was created in the new group,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ run;
|
|||||||
%let checkid=0;
|
%let checkid=0;
|
||||||
data _null_;
|
data _null_;
|
||||||
set work.test2;
|
set work.test2;
|
||||||
where name="&group";
|
where upcase(name)="%upcase(&group)";
|
||||||
call symputx('checkid',groupid);
|
call symputx('checkid',groupid);
|
||||||
run;
|
run;
|
||||||
%mp_assert(
|
%mp_assert(
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
data _null_;
|
data _null_;
|
||||||
set work.test1;
|
set work.test1;
|
||||||
call symputx('id',id);
|
call symputx('id',id);
|
||||||
|
putlog (_all_)(=);
|
||||||
run;
|
run;
|
||||||
%mp_assert(
|
%mp_assert(
|
||||||
iftrue=(&id>0),
|
iftrue=(&id>0),
|
||||||
@@ -35,7 +36,8 @@ run;
|
|||||||
%let checkid=0;
|
%let checkid=0;
|
||||||
data _null_;
|
data _null_;
|
||||||
set work.test2;
|
set work.test2;
|
||||||
where username="&user";
|
if _n_<20 then putlog (_all_)(=);
|
||||||
|
if upcase(username)="%upcase(&user)";
|
||||||
call symputx('checkid',id);
|
call symputx('checkid',id);
|
||||||
run;
|
run;
|
||||||
%mp_assert(
|
%mp_assert(
|
||||||
|
|||||||
@@ -3,21 +3,64 @@
|
|||||||
@brief Testing ms_getgroups.sas macro
|
@brief Testing ms_getgroups.sas macro
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_getuniquename.sas
|
||||||
|
@li ms_adduser2group.sas
|
||||||
|
@li ms_creategroup.sas
|
||||||
@li ms_getgroups.sas
|
@li ms_getgroups.sas
|
||||||
|
@li mp_assert.sas
|
||||||
@li mp_assertdsobs.sas
|
@li mp_assertdsobs.sas
|
||||||
@li mp_assertscope.sas
|
@li mp_assertscope.sas
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
/* create a group */
|
||||||
|
%let group=%substr(%mf_getuniquename(),1,8);
|
||||||
|
%ms_creategroup(&group, desc=The description,mdebug=&sasjs_mdebug,outds=test1)
|
||||||
|
|
||||||
|
/* get groups */
|
||||||
%mp_assertscope(SNAPSHOT)
|
%mp_assertscope(SNAPSHOT)
|
||||||
%ms_getgroups(outds=work.test1,mdebug=&sasjs_mdebug)
|
%ms_getgroups(outds=work.test1,mdebug=&sasjs_mdebug)
|
||||||
%mp_assertscope(COMPARE
|
%mp_assertscope(COMPARE
|
||||||
,ignorelist=MCLIB0_JADP1LEN MCLIB0_JADPNUM MCLIB0_JADVLEN
|
,ignorelist=MCLIB0_JADP1LEN MCLIB0_JADPNUM MCLIB0_JADVLEN
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/* check the group was created */
|
||||||
%mp_assertdsobs(work.test1,test=ATLEAST 1)
|
%mp_assertdsobs(work.test1,test=ATLEAST 1)
|
||||||
|
|
||||||
|
%let test2=0;
|
||||||
|
%put &=group;
|
||||||
|
data _null_;
|
||||||
|
set work.test1;
|
||||||
|
putlog (_all_)(=);
|
||||||
|
if upcase(name)="%upcase(&group)" then do;
|
||||||
|
putlog "&group found!";
|
||||||
|
call symputx('test2',1);
|
||||||
|
call symputx('gid',groupid); /* used in next test */
|
||||||
|
end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=("&test2"="1"),
|
||||||
|
desc=Checking group was created,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
/* now check if the filter for the groups for a user works */
|
||||||
|
|
||||||
|
/* add a member */
|
||||||
|
%ms_adduser2group(uid=1,gid=&gid)
|
||||||
|
|
||||||
|
%ms_getgroups(user=secretuser,outds=work.test3)
|
||||||
|
|
||||||
|
%let test3=0;
|
||||||
|
data _null_;
|
||||||
|
set work.test3;
|
||||||
|
if groupid=&gid then call symputx('test3',1);
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=("&test3"="1"),
|
||||||
|
desc=Checking group list was returned for a user,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
@brief Testing ms_getusers.sas macro
|
@brief Testing ms_getusers.sas macro
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
|
@li ms_creategroup.sas
|
||||||
|
@li ms_adduser2group.sas
|
||||||
@li ms_getusers.sas
|
@li ms_getusers.sas
|
||||||
@li mp_assertdsobs.sas
|
@li mp_assertdsobs.sas
|
||||||
@li mp_assertscope.sas
|
@li mp_assertscope.sas
|
||||||
@@ -18,6 +20,39 @@
|
|||||||
|
|
||||||
%mp_assertdsobs(work.test1,test=ATLEAST 1)
|
%mp_assertdsobs(work.test1,test=ATLEAST 1)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test the extraction of group members
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* create a group */
|
||||||
|
%let group=%substr(%mf_getuniquename(),1,8);
|
||||||
|
%ms_creategroup(&group, desc=some desc,mdebug=&sasjs_mdebug,outds=work.group)
|
||||||
|
%let gid=0;
|
||||||
|
data _null_;
|
||||||
|
set work.group;
|
||||||
|
call symputx('gid',groupid);
|
||||||
|
run;
|
||||||
|
|
||||||
|
/* add a member */
|
||||||
|
%ms_adduser2group(uid=1,gid=&gid)
|
||||||
|
|
||||||
|
/* extract the members */
|
||||||
|
%ms_getusers(group=&group,outds=test2)
|
||||||
|
|
||||||
|
/* check the user is in the output list */
|
||||||
|
%let checkid=0;
|
||||||
|
data _null_;
|
||||||
|
set work.test2;
|
||||||
|
if id=1 then call symputx('checkid',1);
|
||||||
|
run;
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(&checkid=1),
|
||||||
|
desc=Checking that admin user was created in the new group,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ options mprint;
|
|||||||
)
|
)
|
||||||
%mp_assertscope(COMPARE)
|
%mp_assertscope(COMPARE)
|
||||||
|
|
||||||
libname webeen json (weboot);
|
libname webeen json fileref=weboot;
|
||||||
|
|
||||||
data _null_;
|
data _null_;
|
||||||
infile weboot;
|
infile weboot;
|
||||||
|
|||||||
@@ -10,7 +10,12 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
filename ft15f001 temp;
|
filename ft15f001 temp;
|
||||||
parmcards4;
|
data _null_;
|
||||||
|
file ft15f001;
|
||||||
|
infile cards;
|
||||||
|
input;
|
||||||
|
put _infile_;
|
||||||
|
cards4;
|
||||||
%put Initialising sendObj: ;
|
%put Initialising sendObj: ;
|
||||||
%put _all_;
|
%put _all_;
|
||||||
%webout(FETCH)
|
%webout(FETCH)
|
||||||
@@ -27,6 +32,7 @@ parmcards4;
|
|||||||
%mend x; %x()
|
%mend x; %x()
|
||||||
%webout(CLOSE)
|
%webout(CLOSE)
|
||||||
;;;;
|
;;;;
|
||||||
|
run;
|
||||||
%put creating web service: &mcTestAppLoc/services;
|
%put creating web service: &mcTestAppLoc/services;
|
||||||
%ms_createwebservice(
|
%ms_createwebservice(
|
||||||
path=&mcTestAppLoc/services,
|
path=&mcTestAppLoc/services,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ run;
|
|||||||
%ms_webout(OBJ,datasets,fref=&fref)
|
%ms_webout(OBJ,datasets,fref=&fref)
|
||||||
%ms_webout(CLOSE,fref=&fref)
|
%ms_webout(CLOSE,fref=&fref)
|
||||||
|
|
||||||
libname test JSON (&fref);
|
libname test JSON fileref=&fref;
|
||||||
data root;
|
data root;
|
||||||
set test.root;
|
set test.root;
|
||||||
call symputx('checkval',sysvlong);
|
call symputx('checkval',sysvlong);
|
||||||
|
|||||||
@@ -408,7 +408,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 */ ';
|
||||||
@@ -459,18 +459,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 ' ';
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
@file mx_createwebservice.sas
|
@file mx_createwebservice.sas
|
||||||
@brief Create a web service in SAS 9, Viya or SASjs
|
@brief Create a web service in SAS 9, Viya or SASjs
|
||||||
@details Creates a SASJS ready Stored Process in SAS 9, a Job Execution
|
@details Creates a SASJS ready Stored Process in SAS 9, a Job Execution
|
||||||
Service in SAS Viya, and a Stored Program on SASjs Server
|
Service in SAS Viya, or a Stored Program on SASjs Server - depending on the
|
||||||
|
executing environment.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
@@ -24,7 +25,9 @@ Usage:
|
|||||||
%webout(OBJ,example2) * Object format, easier to work with ;
|
%webout(OBJ,example2) * Object format, easier to work with ;
|
||||||
%webout(CLOSE)
|
%webout(CLOSE)
|
||||||
;;;;
|
;;;;
|
||||||
%mp_createwebservice(path=/Public/app/common,name=appInit,replace=YES)
|
|
||||||
|
%* create the service (including webout macro and dependencies);
|
||||||
|
%mx_createwebservice(path=/Public/app/common,name=appInit,replace=YES)
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_getplatform.sas
|
@li mf_getplatform.sas
|
||||||
@@ -43,7 +46,6 @@ Usage:
|
|||||||
location
|
location
|
||||||
@param [in] mDebug= (0) set to 1 to show debug messages in the log
|
@param [in] mDebug= (0) set to 1 to show debug messages in the log
|
||||||
|
|
||||||
@version 9.2
|
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
@param [out] outref= (0) The fileref to create, which will contain the source
|
@param [out] outref= (0) The fileref to create, which will contain the source
|
||||||
code.
|
code.
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_getplatform.sas
|
@li mf_getplatform.sas
|
||||||
@li mm_getstpcode.sas
|
@li mm_getstpcode.sas
|
||||||
@li ms_getfile.sas
|
@li ms_getfile.sas
|
||||||
@@ -34,8 +34,8 @@
|
|||||||
%if &platform=SASJS %then %do;
|
%if &platform=SASJS %then %do;
|
||||||
%ms_getfile(&loc..sas, outref=&outref)
|
%ms_getfile(&loc..sas, outref=&outref)
|
||||||
%end;
|
%end;
|
||||||
%else %if &platform=SAS9 %then %do;
|
%else %if &platform=SAS9 or &platform=SASMETA %then %do;
|
||||||
%mm_getstpcode(tree=&loc,outloc=&outref)
|
%mm_getstpcode(tree=&loc,outref=&outref)
|
||||||
%end;
|
%end;
|
||||||
%else %if &platform=SASVIYA %then %do;
|
%else %if &platform=SASVIYA %then %do;
|
||||||
/* extract name & path from &loc */
|
/* extract name & path from &loc */
|
||||||
|
|||||||
Reference in New Issue
Block a user