1
0
mirror of https://github.com/sasjs/core.git synced 2026-01-07 17:40:05 +00:00

Compare commits

...

10 Commits

12 changed files with 198 additions and 133 deletions

108
all.sas
View File

@@ -380,7 +380,7 @@ options noquotelenmax;
@brief Returns the engine type of a SAS library @brief Returns the engine type of a SAS library
@details Usage: @details Usage:
%put %mf_getEngine(SASHELP); %put %mf_getengine(SASHELP);
returns: returns:
> V9 > V9
@@ -398,9 +398,10 @@ options noquotelenmax;
@version 9.2 @version 9.2
@author Allan Bowe @author Allan Bowe
**/
%macro mf_getEngine(libref **/ /** \cond */
%macro mf_getengine(libref
)/*/STORE SOURCE*/; )/*/STORE SOURCE*/;
%local dsid engnum rc engine; %local dsid engnum rc engine;
@@ -419,7 +420,8 @@ options noquotelenmax;
&engine &engine
%mend; %mend;
/**
/** \endcond *//**
@file @file
@brief Returns the size of a file in bytes. @brief Returns the size of a file in bytes.
@details Provide full path/filename.extension to the file, eg: @details Provide full path/filename.extension to the file, eg:
@@ -1316,13 +1318,23 @@ Usage:
**/ **/
%macro mf_trimstr(basestr,trimstr); %macro mf_trimstr(basestr,trimstr);
%local trimlen trimval; %local baselen trimlen trimval;
/* return if basestr is shorter than trimstr (or 0) */
%let baselen=%length(%superq(basestr));
%let trimlen=%length(%superq(trimstr)); %let trimlen=%length(%superq(trimstr));
%if &baselen < &trimlen or &baselen=0 %then %return;
/* obtain the characters from the end of basestr */
%let trimval=%qsubstr(%superq(basestr) %let trimval=%qsubstr(%superq(basestr)
,%length(%superq(basestr))-&trimlen+1 ,%length(%superq(basestr))-&trimlen+1
,&trimlen); ,&trimlen);
%if %superq(trimval)=%superq(trimstr) %then %do; /* compare and if matching, chop it off! */
%if %superq(basestr)=%superq(trimstr) %then %do;
%return;
%end;
%else %if %superq(trimval)=%superq(trimstr) %then %do;
%qsubstr(%superq(basestr),1,%length(%superq(basestr))-&trimlen) %qsubstr(%superq(basestr),1,%length(%superq(basestr))-&trimlen)
%end; %end;
%else %do; %else %do;
@@ -1541,8 +1553,15 @@ Usage:
%end; %end;
%if %symexist(SYS_JES_JOB_URI) %then %do; %if %symexist(SYS_JES_JOB_URI) %then %do;
/* refer web service output to file service in one hit */ /* setup webout */
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name="_webout.json"; OPTIONS NOBOMFILE;
%if "X&SYS_JES_JOB_URI.X"="XX" %then %do;
filename _webout temp lrecl=999999 mod;
%end;
%else %do;
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI"
name="_webout.json" lrecl=999999 mod;
%end;
%end; %end;
/* send response in SASjs JSON format */ /* send response in SASjs JSON format */
@@ -1957,6 +1976,8 @@ run;
%mp_dirlist(outds=cwdfileprops, getattrs=YES) %mp_dirlist(outds=cwdfileprops, getattrs=YES)
%mp_dirlist(fref=MYFREF)
@warning In a Unix environment, the existence of a named pipe will cause this @warning In a Unix environment, the existence of a named pipe will cause this
macro to hang. Therefore this tool should be used with caution in a SAS 9 web macro to hang. Therefore this tool should be used with caution in a SAS 9 web
application, as it can use up all available multibridge sessions if requests application, as it can use up all available multibridge sessions if requests
@@ -1966,12 +1987,14 @@ run;
@param path= for which to return contents @param path= for which to return contents
@param fref= Provide a DISK engine fileref as an alternative to PATH
@param outds= the output dataset to create @param outds= the output dataset to create
@param getattrs= YES/NO (default=NO). Uses doptname and foptname to return @param getattrs= YES/NO (default=NO). Uses doptname and foptname to return
all attributes for each file / folder. all attributes for each file / folder.
@returns outds contains the following variables: @returns outds contains the following variables:
- directory (containing folder)
- file_or_folder (file / folder) - file_or_folder (file / folder)
- filepath (path/to/file.name) - filepath (path/to/file.name)
- filename (just the file name) - filename (just the file name)
@@ -1984,18 +2007,26 @@ run;
**/ **/
%macro mp_dirlist(path=%sysfunc(pathname(work)) %macro mp_dirlist(path=%sysfunc(pathname(work))
, fref=0
, outds=work.mp_dirlist , outds=work.mp_dirlist
, getattrs=NO , getattrs=NO
)/*/STORE SOURCE*/; )/*/STORE SOURCE*/;
%let getattrs=%upcase(&getattrs)XX; %let getattrs=%upcase(&getattrs)XX;
data &outds (compress=no keep=file_or_folder filepath filename ext msg); data &outds (compress=no keep=file_or_folder filepath filename ext msg directory);
length filepath $500 fref fref2 $8 file_or_folder $6 filename $80 ext $20 msg $200; length directory filepath $500 fref fref2 $8 file_or_folder $6 filename $80 ext $20 msg $200;
rc = filename(fref, "&path"); %if &fref=0 %then %do;
rc = filename(fref, "&path");
%end;
%else %do;
fref="&fref";
rc=0;
%end;
if rc = 0 then do; if rc = 0 then do;
did = dopen(fref); did = dopen(fref);
directory=dinfo(did,'Directory');
if did=0 then do; if did=0 then do;
putlog "NOTE: This directory is empty - &path"; putlog "NOTE: This directory is empty - " directory;
msg=sysmsg(); msg=sysmsg();
put _all_; put _all_;
stop; stop;
@@ -2010,7 +2041,8 @@ data &outds (compress=no keep=file_or_folder filepath filename ext msg);
dnum = dnum(did); dnum = dnum(did);
do i = 1 to dnum; do i = 1 to dnum;
filename = dread(did, i); filename = dread(did, i);
rc = filename(fref2, "&path/"!!filename); filepath=cats(directory,'/',filename);
rc = filename(fref2,filepath);
midd=dopen(fref2); midd=dopen(fref2);
dmsg=sysmsg(); dmsg=sysmsg();
if did > 0 then file_or_folder='folder'; if did > 0 then file_or_folder='folder';
@@ -2033,7 +2065,6 @@ data &outds (compress=no keep=file_or_folder filepath filename ext msg);
ext=''; ext='';
file_or_folder='folder'; file_or_folder='folder';
end; end;
filepath="&path/"!!filename;
output; output;
end; end;
rc = dclose(did); rc = dclose(did);
@@ -2280,8 +2311,7 @@ proc sql
order by ranuni(42) order by ranuni(42)
%end; %end;
; ;
reset outobs=max;
create table datalines1 as create table datalines1 as
select name,type,length,varnum,format,label from dictionary.columns select name,type,length,varnum,format,label from dictionary.columns
where libname="%upcase(%scan(&base_ds,1))" where libname="%upcase(%scan(&base_ds,1))"
@@ -2511,7 +2541,6 @@ create table &outds as
datetime2 format or regular decimal type datetime2 format or regular decimal type
@version 9.3 @version 9.3
@author Allan Bowe @author Allan Bowe
@source https://github.com/sasjs/core
**/ **/
%macro mp_getddl(libref,ds,fref=getddl,flavour=SAS,showlog=NO,schema= %macro mp_getddl(libref,ds,fref=getddl,flavour=SAS,showlog=NO,schema=
@@ -2820,7 +2849,7 @@ run;
%end; %end;
%end; %end;
%if &showlog=YES %then %do; %if %upcase(&showlog)=YES %then %do;
options ps=max; options ps=max;
data _null_; data _null_;
infile &fref; infile &fref;
@@ -2905,9 +2934,9 @@ create table &outds (rename=(
@brief Guess the primary key of a table @brief Guess the primary key of a table
@details Tries to guess the primary key of a table based on the following logic: @details Tries to guess the primary key of a table based on the following logic:
* Columns with nulls are ignored * Columns with nulls are ignored
* Return only column combinations that provide unique results * Return only column combinations that provide unique results
* Start from one column, then move out to include composite keys of 2 to 6 columns * Start from one column, then move out to include composite keys of 2 to 6 columns
The library of the target should be assigned before using this macro. The library of the target should be assigned before using this macro.
@@ -3703,7 +3732,7 @@ proc sort; by descending sumcols memname libname; run;
@brief Searches all data in a library @brief Searches all data in a library
@details @details
Scans an entire library and creates a copy of any table Scans an entire library and creates a copy of any table
containing a specific string or numeric value. Only containing a specific string OR numeric value. Only
matching records are written out. matching records are written out.
If both a string and numval are provided, the string If both a string and numval are provided, the string
will take precedence. will take precedence.
@@ -3744,9 +3773,13 @@ proc sort; by descending sumcols memname libname; run;
,filter_text=%str(1=1) ,filter_text=%str(1=1)
)/*/STORE SOURCE*/; )/*/STORE SOURCE*/;
%local table_list table table_num table colnum col start_tm vars type coltype; %local table_list table table_num table colnum col start_tm check_tm vars type coltype;
%put process began at %sysfunc(datetime(),datetime19.); %put process began at %sysfunc(datetime(),datetime19.);
%if &syscc ge 4 %then %do;
%put %str(WAR)NING: SYSCC=&syscc on macro entry;
%return;
%end;
%if &string = %then %let type=N; %if &string = %then %let type=N;
%else %let type=C; %else %let type=C;
@@ -3778,6 +3811,7 @@ proc sql
%put NO COLUMNS IN &lib..&table! This will be skipped.; %put NO COLUMNS IN &lib..&table! This will be skipped.;
%end; %end;
%else %do; %else %do;
%let check_tm=%sysfunc(datetime());
/* build sql statement */ /* build sql statement */
create table mpsearch.&table as select * from &lib..&table create table mpsearch.&table as select * from &lib..&table
where %unquote(&filter_text) and where %unquote(&filter_text) and
@@ -3788,14 +3822,19 @@ proc sql
%let coltype=%mf_getvartype(&lib..&table,&col); %let coltype=%mf_getvartype(&lib..&table,&col);
%if &type=C and &coltype=C %then %do; %if &type=C and &coltype=C %then %do;
/* if a char column, see if it contains the string */ /* if a char column, see if it contains the string */
or (&col ? "&string") or ("&col"n ? "&string")
%end; %end;
%else %if &type=N and &coltype=N %then %do; %else %if &type=N and &coltype=N %then %do;
/* if numeric match exactly */ /* if numeric match exactly */
or (&col = &numval) or ("&col"n = &numval)
%end; %end;
%end; %end;
); );
%put Search query for &table took %sysevalf(%sysfunc(datetime())-&check_tm) seconds;
%if &sqlrc ne 0 %then %do;
%put %str(WAR)NING: SQLRC=&sqlrc when processing &table;
%return;
%end;
%if %mf_nobs(mpsearch.&table)=0 %then %do; %if %mf_nobs(mpsearch.&table)=0 %then %do;
drop table mpsearch.&table; drop table mpsearch.&table;
%end; %end;
@@ -11452,24 +11491,15 @@ libname &libref1 clear;
%mend;/** %mend;/**
@file mv_getusergroups.sas @file mv_getusergroups.sas
@brief Creates a dataset with a list of groups for a particular user @brief Creates a dataset with a list of groups for a particular user
@details First, be sure you have an access token (which requires an app token). @details If using outside of Viya SPRE, then an access token is needed.
Using the macros here: Compile the macros here:
filename mc url filename mc url
"https://raw.githubusercontent.com/sasjs/core/main/all.sas"; "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
%inc mc; %inc mc;
An administrator needs to set you up with an access code: Then run the macro!
%mv_registerclient(outds=client)
Navigate to the url from the log (opting in to the groups) and paste the
access code below:
%mv_tokenauth(inds=client,code=wKDZYTEPK6)
Now we can run the macro!
%mv_getusergroups(&sysuserid,outds=users) %mv_getusergroups(&sysuserid,outds=users)
@@ -11855,7 +11885,7 @@ run;
%end; %end;
/* prepare url */ /* prepare url */
%if &grant_type=authorization_code %then %do; %if %index(%superq(grant_type),authorization_code) %then %do;
data _null_; data _null_;
if symexist('_baseurl') then do; if symexist('_baseurl') then do;
url=symget('_baseurl'); url=symget('_baseurl');
@@ -11874,7 +11904,7 @@ run;
%put CLIENT_SECRET=&client_secret; %put CLIENT_SECRET=&client_secret;
%put GRANT_TYPE=&grant_type; %put GRANT_TYPE=&grant_type;
%put; %put;
%if &grant_type=authorization_code %then %do; %if %index(%superq(grant_type),authorization_code) %then %do;
/* cannot use base_uri here as it includes the protocol which may be incorrect externally */ /* cannot use base_uri here as it includes the protocol which may be incorrect externally */
%put NOTE: The developer must also register below and select 'openid' to get the grant code:; %put NOTE: The developer must also register below and select 'openid' to get the grant code:;
%put NOTE- ; %put NOTE- ;

View File

@@ -3,7 +3,7 @@
@brief Returns the engine type of a SAS library @brief Returns the engine type of a SAS library
@details Usage: @details Usage:
%put %mf_getEngine(SASHELP); %put %mf_getengine(SASHELP);
returns: returns:
> V9 > V9
@@ -21,9 +21,10 @@
@version 9.2 @version 9.2
@author Allan Bowe @author Allan Bowe
**/
%macro mf_getEngine(libref **/ /** \cond */
%macro mf_getengine(libref
)/*/STORE SOURCE*/; )/*/STORE SOURCE*/;
%local dsid engnum rc engine; %local dsid engnum rc engine;
@@ -42,3 +43,5 @@
&engine &engine
%mend; %mend;
/** \endcond */

View File

@@ -23,13 +23,23 @@
**/ **/
%macro mf_trimstr(basestr,trimstr); %macro mf_trimstr(basestr,trimstr);
%local trimlen trimval; %local baselen trimlen trimval;
/* return if basestr is shorter than trimstr (or 0) */
%let baselen=%length(%superq(basestr));
%let trimlen=%length(%superq(trimstr)); %let trimlen=%length(%superq(trimstr));
%if &baselen < &trimlen or &baselen=0 %then %return;
/* obtain the characters from the end of basestr */
%let trimval=%qsubstr(%superq(basestr) %let trimval=%qsubstr(%superq(basestr)
,%length(%superq(basestr))-&trimlen+1 ,%length(%superq(basestr))-&trimlen+1
,&trimlen); ,&trimlen);
%if %superq(trimval)=%superq(trimstr) %then %do; /* compare and if matching, chop it off! */
%if %superq(basestr)=%superq(trimstr) %then %do;
%return;
%end;
%else %if %superq(trimval)=%superq(trimstr) %then %do;
%qsubstr(%superq(basestr),1,%length(%superq(basestr))-&trimlen) %qsubstr(%superq(basestr),1,%length(%superq(basestr))-&trimlen)
%end; %end;
%else %do; %else %do;

View File

@@ -71,8 +71,15 @@
%end; %end;
%if %symexist(SYS_JES_JOB_URI) %then %do; %if %symexist(SYS_JES_JOB_URI) %then %do;
/* refer web service output to file service in one hit */ /* setup webout */
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name="_webout.json"; OPTIONS NOBOMFILE;
%if "X&SYS_JES_JOB_URI.X"="XX" %then %do;
filename _webout temp lrecl=999999 mod;
%end;
%else %do;
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI"
name="_webout.json" lrecl=999999 mod;
%end;
%end; %end;
/* send response in SASjs JSON format */ /* send response in SASjs JSON format */

View File

@@ -20,6 +20,8 @@
%mp_dirlist(outds=cwdfileprops, getattrs=YES) %mp_dirlist(outds=cwdfileprops, getattrs=YES)
%mp_dirlist(fref=MYFREF)
@warning In a Unix environment, the existence of a named pipe will cause this @warning In a Unix environment, the existence of a named pipe will cause this
macro to hang. Therefore this tool should be used with caution in a SAS 9 web macro to hang. Therefore this tool should be used with caution in a SAS 9 web
application, as it can use up all available multibridge sessions if requests application, as it can use up all available multibridge sessions if requests
@@ -29,12 +31,14 @@
@param path= for which to return contents @param path= for which to return contents
@param fref= Provide a DISK engine fileref as an alternative to PATH
@param outds= the output dataset to create @param outds= the output dataset to create
@param getattrs= YES/NO (default=NO). Uses doptname and foptname to return @param getattrs= YES/NO (default=NO). Uses doptname and foptname to return
all attributes for each file / folder. all attributes for each file / folder.
@returns outds contains the following variables: @returns outds contains the following variables:
- directory (containing folder)
- file_or_folder (file / folder) - file_or_folder (file / folder)
- filepath (path/to/file.name) - filepath (path/to/file.name)
- filename (just the file name) - filename (just the file name)
@@ -47,18 +51,26 @@
**/ **/
%macro mp_dirlist(path=%sysfunc(pathname(work)) %macro mp_dirlist(path=%sysfunc(pathname(work))
, fref=0
, outds=work.mp_dirlist , outds=work.mp_dirlist
, getattrs=NO , getattrs=NO
)/*/STORE SOURCE*/; )/*/STORE SOURCE*/;
%let getattrs=%upcase(&getattrs)XX; %let getattrs=%upcase(&getattrs)XX;
data &outds (compress=no keep=file_or_folder filepath filename ext msg); data &outds (compress=no keep=file_or_folder filepath filename ext msg directory);
length filepath $500 fref fref2 $8 file_or_folder $6 filename $80 ext $20 msg $200; length directory filepath $500 fref fref2 $8 file_or_folder $6 filename $80 ext $20 msg $200;
rc = filename(fref, "&path"); %if &fref=0 %then %do;
rc = filename(fref, "&path");
%end;
%else %do;
fref="&fref";
rc=0;
%end;
if rc = 0 then do; if rc = 0 then do;
did = dopen(fref); did = dopen(fref);
directory=dinfo(did,'Directory');
if did=0 then do; if did=0 then do;
putlog "NOTE: This directory is empty - &path"; putlog "NOTE: This directory is empty - " directory;
msg=sysmsg(); msg=sysmsg();
put _all_; put _all_;
stop; stop;
@@ -73,7 +85,8 @@ data &outds (compress=no keep=file_or_folder filepath filename ext msg);
dnum = dnum(did); dnum = dnum(did);
do i = 1 to dnum; do i = 1 to dnum;
filename = dread(did, i); filename = dread(did, i);
rc = filename(fref2, "&path/"!!filename); filepath=cats(directory,'/',filename);
rc = filename(fref2,filepath);
midd=dopen(fref2); midd=dopen(fref2);
dmsg=sysmsg(); dmsg=sysmsg();
if did > 0 then file_or_folder='folder'; if did > 0 then file_or_folder='folder';
@@ -96,7 +109,6 @@ data &outds (compress=no keep=file_or_folder filepath filename ext msg);
ext=''; ext='';
file_or_folder='folder'; file_or_folder='folder';
end; end;
filepath="&path/"!!filename;
output; output;
end; end;
rc = dclose(did); rc = dclose(did);

View File

@@ -103,8 +103,7 @@ proc sql
order by ranuni(42) order by ranuni(42)
%end; %end;
; ;
reset outobs=max;
create table datalines1 as create table datalines1 as
select name,type,length,varnum,format,label from dictionary.columns select name,type,length,varnum,format,label from dictionary.columns
where libname="%upcase(%scan(&base_ds,1))" where libname="%upcase(%scan(&base_ds,1))"

View File

@@ -30,7 +30,6 @@
datetime2 format or regular decimal type datetime2 format or regular decimal type
@version 9.3 @version 9.3
@author Allan Bowe @author Allan Bowe
@source https://github.com/sasjs/core
**/ **/
%macro mp_getddl(libref,ds,fref=getddl,flavour=SAS,showlog=NO,schema= %macro mp_getddl(libref,ds,fref=getddl,flavour=SAS,showlog=NO,schema=
@@ -339,7 +338,7 @@ run;
%end; %end;
%end; %end;
%if &showlog=YES %then %do; %if %upcase(&showlog)=YES %then %do;
options ps=max; options ps=max;
data _null_; data _null_;
infile &fref; infile &fref;

View File

@@ -3,9 +3,9 @@
@brief Guess the primary key of a table @brief Guess the primary key of a table
@details Tries to guess the primary key of a table based on the following logic: @details Tries to guess the primary key of a table based on the following logic:
* Columns with nulls are ignored * Columns with nulls are ignored
* Return only column combinations that provide unique results * Return only column combinations that provide unique results
* Start from one column, then move out to include composite keys of 2 to 6 columns * Start from one column, then move out to include composite keys of 2 to 6 columns
The library of the target should be assigned before using this macro. The library of the target should be assigned before using this macro.

View File

@@ -3,7 +3,7 @@
@brief Searches all data in a library @brief Searches all data in a library
@details @details
Scans an entire library and creates a copy of any table Scans an entire library and creates a copy of any table
containing a specific string or numeric value. Only containing a specific string OR numeric value. Only
matching records are written out. matching records are written out.
If both a string and numval are provided, the string If both a string and numval are provided, the string
will take precedence. will take precedence.
@@ -44,9 +44,13 @@
,filter_text=%str(1=1) ,filter_text=%str(1=1)
)/*/STORE SOURCE*/; )/*/STORE SOURCE*/;
%local table_list table table_num table colnum col start_tm vars type coltype; %local table_list table table_num table colnum col start_tm check_tm vars type coltype;
%put process began at %sysfunc(datetime(),datetime19.); %put process began at %sysfunc(datetime(),datetime19.);
%if &syscc ge 4 %then %do;
%put %str(WAR)NING: SYSCC=&syscc on macro entry;
%return;
%end;
%if &string = %then %let type=N; %if &string = %then %let type=N;
%else %let type=C; %else %let type=C;
@@ -78,6 +82,7 @@ proc sql
%put NO COLUMNS IN &lib..&table! This will be skipped.; %put NO COLUMNS IN &lib..&table! This will be skipped.;
%end; %end;
%else %do; %else %do;
%let check_tm=%sysfunc(datetime());
/* build sql statement */ /* build sql statement */
create table mpsearch.&table as select * from &lib..&table create table mpsearch.&table as select * from &lib..&table
where %unquote(&filter_text) and where %unquote(&filter_text) and
@@ -88,14 +93,19 @@ proc sql
%let coltype=%mf_getvartype(&lib..&table,&col); %let coltype=%mf_getvartype(&lib..&table,&col);
%if &type=C and &coltype=C %then %do; %if &type=C and &coltype=C %then %do;
/* if a char column, see if it contains the string */ /* if a char column, see if it contains the string */
or (&col ? "&string") or ("&col"n ? "&string")
%end; %end;
%else %if &type=N and &coltype=N %then %do; %else %if &type=N and &coltype=N %then %do;
/* if numeric match exactly */ /* if numeric match exactly */
or (&col = &numval) or ("&col"n = &numval)
%end; %end;
%end; %end;
); );
%put Search query for &table took %sysevalf(%sysfunc(datetime())-&check_tm) seconds;
%if &sqlrc ne 0 %then %do;
%put %str(WAR)NING: SQLRC=&sqlrc when processing &table;
%return;
%end;
%if %mf_nobs(mpsearch.&table)=0 %then %do; %if %mf_nobs(mpsearch.&table)=0 %then %do;
drop table mpsearch.&table; drop table mpsearch.&table;
%end; %end;

View File

@@ -36,5 +36,9 @@ echo 'core.sasjs.io' > CNAME
git add * git add *
git commit -m "build.sh build on $(date +%F:%H:%M:%S)" git commit -m "build.sh build on $(date +%F:%H:%M:%S)"
git push git push
npx sitemap-generator-cli https://core.sasjs.io
git add *
git commit -m "adding sitemap"
git push
echo "check it out: https://sasjs.github.io/core.github.io/files.html" echo "check it out: https://sasjs.github.io/core.github.io/files.html"

View File

@@ -1,24 +1,15 @@
/** /**
@file mv_getusergroups.sas @file mv_getusergroups.sas
@brief Creates a dataset with a list of groups for a particular user @brief Creates a dataset with a list of groups for a particular user
@details First, be sure you have an access token (which requires an app token). @details If using outside of Viya SPRE, then an access token is needed.
Using the macros here: Compile the macros here:
filename mc url filename mc url
"https://raw.githubusercontent.com/sasjs/core/main/all.sas"; "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
%inc mc; %inc mc;
An administrator needs to set you up with an access code: Then run the macro!
%mv_registerclient(outds=client)
Navigate to the url from the log (opting in to the groups) and paste the
access code below:
%mv_tokenauth(inds=client,code=wKDZYTEPK6)
Now we can run the macro!
%mv_getusergroups(&sysuserid,outds=users) %mv_getusergroups(&sysuserid,outds=users)

View File

@@ -187,7 +187,7 @@ run;
%end; %end;
/* prepare url */ /* prepare url */
%if &grant_type=authorization_code %then %do; %if %index(%superq(grant_type),authorization_code) %then %do;
data _null_; data _null_;
if symexist('_baseurl') then do; if symexist('_baseurl') then do;
url=symget('_baseurl'); url=symget('_baseurl');
@@ -206,7 +206,7 @@ run;
%put CLIENT_SECRET=&client_secret; %put CLIENT_SECRET=&client_secret;
%put GRANT_TYPE=&grant_type; %put GRANT_TYPE=&grant_type;
%put; %put;
%if &grant_type=authorization_code %then %do; %if %index(%superq(grant_type),authorization_code) %then %do;
/* cannot use base_uri here as it includes the protocol which may be incorrect externally */ /* cannot use base_uri here as it includes the protocol which may be incorrect externally */
%put NOTE: The developer must also register below and select 'openid' to get the grant code:; %put NOTE: The developer must also register below and select 'openid' to get the grant code:;
%put NOTE- ; %put NOTE- ;