mirror of
https://github.com/sasjs/core.git
synced 2026-01-03 23:50:06 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
029169ac80 | ||
| 66ff1de7a9 | |||
| 053290c7df | |||
| af71a5e53b | |||
| ecdce86287 | |||
| ba1272aaf7 | |||
| d6056b9397 | |||
|
|
00511c72c2 | ||
|
|
1d6f04fd56 | ||
| af4dbb5632 | |||
|
|
f48c291dce | ||
|
|
18be74a1c2 | ||
|
|
456d10a90e |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -6,4 +6,7 @@ sasjsbuild/
|
|||||||
**\ **
|
**\ **
|
||||||
|
|
||||||
# ignore the mc_* files - containing macros for individual libraries
|
# ignore the mc_* files - containing macros for individual libraries
|
||||||
mc_*
|
mc_*
|
||||||
|
|
||||||
|
# ignore .env files as they can contain sasjs access tokens
|
||||||
|
*.env*
|
||||||
@@ -5,4 +5,4 @@ image:
|
|||||||
file: .gitpod.dockerfile
|
file: .gitpod.dockerfile
|
||||||
vscode:
|
vscode:
|
||||||
extensions:
|
extensions:
|
||||||
- sasjs.sasjs-for-vscode@1.7.2:R6y1nzpFh2P99BZg5FgH5g==
|
- sasjs.sasjs-for-vscode
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
"noTrailingSpaces": true,
|
"noTrailingSpaces": true,
|
||||||
"noEncodedPasswords": true,
|
"noEncodedPasswords": true,
|
||||||
"hasDoxygenHeader": true,
|
"hasDoxygenHeader": true,
|
||||||
|
"hasMacroNameInMend": false,
|
||||||
|
"hasMacroParentheses": true,
|
||||||
|
"noNestedMacros": false,
|
||||||
"noSpacesInFileNames": true,
|
"noSpacesInFileNames": true,
|
||||||
"maxLineLength": 135,
|
"maxLineLength": 135,
|
||||||
"lowerCaseFileNames": true,
|
"lowerCaseFileNames": true,
|
||||||
|
|||||||
5
.vscode/extensions.json
vendored
Normal file
5
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"recommendations": [
|
||||||
|
"sasjs.sasjs-for-vscode"
|
||||||
|
]
|
||||||
|
}
|
||||||
170
all.sas
170
all.sas
@@ -3913,14 +3913,91 @@ create table &outds (rename=(
|
|||||||
%return;
|
%return;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
|
%mend;/**
|
||||||
|
@file
|
||||||
|
@brief Returns a unique hash for a dataset
|
||||||
|
@details Ignores metadata attributes, used only to hash values. Compared
|
||||||
|
datasets must be in the same order.
|
||||||
|
|
||||||
|
%mp_hashdataset(sashelp.class,outds=myhash)
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
set work.myhash;
|
||||||
|
put hashkey=;
|
||||||
|
run;
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_getattrn.sas
|
||||||
|
@li mf_getuniquename.sas
|
||||||
|
@li mf_getvarlist.sas
|
||||||
|
@li mf_getvartype.sas
|
||||||
|
|
||||||
|
@param [in] libds dataset to hash
|
||||||
|
@param [out] outds= (work.mf_hashdataset) The output dataset to create. This
|
||||||
|
will contain one column (hashkey) with one observation (a hex32.
|
||||||
|
representation of the input hash)
|
||||||
|
|hashkey:$32.|
|
||||||
|
|---|
|
||||||
|
|28ABC74ABFC45F50794237BA5566E6CA|
|
||||||
|
|
||||||
|
@version 9.2
|
||||||
|
@author Allan Bowe
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mp_hashdataset(
|
||||||
|
libds,
|
||||||
|
outds=
|
||||||
|
)/*/STORE SOURCE*/;
|
||||||
|
%if %mf_getattrn(&libds,NLOBS)=0 %then %do;
|
||||||
|
%put %str(WARN)ING: Dataset &libds is empty;, or is not a dataset;
|
||||||
|
%end;
|
||||||
|
%else %if %mf_getattrn(&libds,NLOBS)<0 %then %do;
|
||||||
|
%put %str(ERR)OR: Dataset &libds is not a dataset;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
%local keyvar /* roll up the md5 */
|
||||||
|
prevkeyvar /* retain prev record md5 */
|
||||||
|
lastvar /* last var in input ds */
|
||||||
|
varlist var i;
|
||||||
|
/* avoid naming conflict for hash key vars */
|
||||||
|
%let keyvar=%mf_getuniquename();
|
||||||
|
%let prevkeyvar=%mf_getuniquename();
|
||||||
|
%let lastvar=%mf_getuniquename();
|
||||||
|
%let varlist=%mf_getvarlist(&libds);
|
||||||
|
data &outds(rename=(&keyvar=hashkey) keep=&keyvar);
|
||||||
|
length &prevkeyvar &keyvar $32;
|
||||||
|
retain &prevkeyvar;
|
||||||
|
set &libds end=&lastvar;
|
||||||
|
/* hash should include previous row */
|
||||||
|
if _n_>1 then &keyvar=put(md5(&prevkeyvar
|
||||||
|
/* loop every column, hashing every individual value */
|
||||||
|
%do i=1 %to %sysfunc(countw(&varlist));
|
||||||
|
%let var=%scan(&varlist,&i,%str( ));
|
||||||
|
%if %mf_getvartype(&libds,&var)=C %then %do;
|
||||||
|
!!put(md5(trim(&var)),$hex32.)
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
!!put(md5(trim(put(&var*1,binary64.))),$hex32.)
|
||||||
|
%end;
|
||||||
|
%end;
|
||||||
|
),$hex32.);
|
||||||
|
&prevkeyvar=&keyvar;
|
||||||
|
if &lastvar then output;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
%mend;/**
|
%mend;/**
|
||||||
@file mp_jsonout.sas
|
@file mp_jsonout.sas
|
||||||
@brief Writes JSON in SASjs format to a fileref
|
@brief Writes JSON in SASjs format to a fileref
|
||||||
@details PROC JSON is faster but will produce errs like the ones below if
|
@details PROC JSON is faster but will produce errs like the ones below if
|
||||||
special chars are encountered.
|
special chars are encountered.
|
||||||
|
|
||||||
>An object or array close is not valid at this point in the JSON text.
|
> ERROR: Some code points did not transcode.
|
||||||
>Date value out of range
|
|
||||||
|
> An object or array close is not valid at this point in the JSON text.
|
||||||
|
|
||||||
|
> Date value out of range
|
||||||
|
|
||||||
If this happens, try running with ENGINE=DATASTEP.
|
If this happens, try running with ENGINE=DATASTEP.
|
||||||
|
|
||||||
@@ -3929,7 +4006,9 @@ create table &outds (rename=(
|
|||||||
filename tmp temp;
|
filename tmp temp;
|
||||||
data class; set sashelp.class;run;
|
data class; set sashelp.class;run;
|
||||||
|
|
||||||
|
%mp_jsonout(OPEN,jref=tmp)
|
||||||
%mp_jsonout(OBJ,class,jref=tmp)
|
%mp_jsonout(OBJ,class,jref=tmp)
|
||||||
|
%mp_jsonout(CLOSE,jref=tmp)
|
||||||
|
|
||||||
data _null_;
|
data _null_;
|
||||||
infile tmp;
|
infile tmp;
|
||||||
@@ -3942,18 +4021,18 @@ create table &outds (rename=(
|
|||||||
For more information see https://sasjs.io
|
For more information see https://sasjs.io
|
||||||
|
|
||||||
@param action Valid values:
|
@param action Valid values:
|
||||||
* OPEN - opens the JSON
|
@li OPEN - opens the JSON
|
||||||
* OBJ - sends a table with each row as an object
|
@li OBJ - sends a table with each row as an object
|
||||||
* ARR - sends a table with each row in an array
|
@li ARR - sends a table with each row in an array
|
||||||
* CLOSE - closes the JSON
|
@li CLOSE - closes the JSON
|
||||||
|
|
||||||
@param ds the dataset to send. Must be a work table.
|
@param ds the dataset to send. Must be a work table.
|
||||||
@param jref= the fileref to which to send the JSON
|
@param jref= the fileref to which to send the JSON
|
||||||
@param dslabel= the name to give the table in the exported JSON
|
@param dslabel= the name to give the table in the exported JSON
|
||||||
@param fmt= Whether to keep or strip formats from the table
|
@param fmt= Whether to keep or strip formats from the table
|
||||||
@param engine= Which engine to use to send the JSON, options are:
|
@param engine= Which engine to use to send the JSON, valid options are:
|
||||||
* PROCJSON (default)
|
@li PROCJSON (default)
|
||||||
* DATASTEP
|
@li DATASTEP (more reliable when data has non standard characters)
|
||||||
|
|
||||||
@param dbg= DEPRECATED - was used to conditionally add PRETTY to
|
@param dbg= DEPRECATED - was used to conditionally add PRETTY to
|
||||||
proc json but this can cause line truncation in large files.
|
proc json but this can cause line truncation in large files.
|
||||||
@@ -4075,11 +4154,12 @@ create table &outds (rename=(
|
|||||||
%end;
|
%end;
|
||||||
|
|
||||||
%else %if &action=CLOSE %then %do;
|
%else %if &action=CLOSE %then %do;
|
||||||
data _null_;file &jref encoding='utf-8';
|
data _null_;file &jref encoding='utf-8' mod;
|
||||||
put "}";
|
put "}";
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
%mend;/**
|
%mend;
|
||||||
|
/**
|
||||||
@file
|
@file
|
||||||
@brief Convert all library members to CARDS files
|
@brief Convert all library members to CARDS files
|
||||||
@details Gets list of members then calls the <code>%mp_ds2cards()</code> macro.
|
@details Gets list of members then calls the <code>%mp_ds2cards()</code> macro.
|
||||||
@@ -7301,8 +7381,6 @@ run;
|
|||||||
*/
|
*/
|
||||||
%mm_updatestpsourcecode(stp=&tree/&stpname
|
%mm_updatestpsourcecode(stp=&tree/&stpname
|
||||||
,stpcode="&directory/&filename"
|
,stpcode="&directory/&filename"
|
||||||
,frefin=&frefin.
|
|
||||||
,frefout=&frefout.
|
|
||||||
,mdebug=&mdebug
|
,mdebug=&mdebug
|
||||||
,minify=&minify)
|
,minify=&minify)
|
||||||
|
|
||||||
@@ -7510,7 +7588,7 @@ data _null_;
|
|||||||
put '%end; ';
|
put '%end; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put '%else %if &action=CLOSE %then %do; ';
|
put '%else %if &action=CLOSE %then %do; ';
|
||||||
put ' data _null_;file &jref encoding=''utf-8''; ';
|
put ' data _null_;file &jref encoding=''utf-8'' mod; ';
|
||||||
put ' put "}"; ';
|
put ' put "}"; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
put '%end; ';
|
put '%end; ';
|
||||||
@@ -7591,14 +7669,14 @@ data _null_;
|
|||||||
put ' i+1; ';
|
put ' i+1; ';
|
||||||
put ' call symputx(''wt''!!left(i),name,''l''); ';
|
put ' call symputx(''wt''!!left(i),name,''l''); ';
|
||||||
put ' call symputx(''wtcnt'',i,''l''); ';
|
put ' call symputx(''wtcnt'',i,''l''); ';
|
||||||
put ' data _null_; file &fref encoding=''utf-8''; ';
|
put ' data _null_; file &fref mod encoding=''utf-8''; ';
|
||||||
put ' put ",""WORK"":{"; ';
|
put ' put ",""WORK"":{"; ';
|
||||||
put ' %do i=1 %to &wtcnt; ';
|
put ' %do i=1 %to &wtcnt; ';
|
||||||
put ' %let wt=&&wt&i; ';
|
put ' %let wt=&&wt&i; ';
|
||||||
put ' proc contents noprint data=&wt ';
|
put ' proc contents noprint data=&wt ';
|
||||||
put ' out=_data_ (keep=name type length format:); ';
|
put ' out=_data_ (keep=name type length format:); ';
|
||||||
put ' run;%let tempds=%scan(&syslast,2,.); ';
|
put ' run;%let tempds=%scan(&syslast,2,.); ';
|
||||||
put ' data _null_; file &fref encoding=''utf-8''; ';
|
put ' data _null_; file &fref mod encoding=''utf-8''; ';
|
||||||
put ' dsid=open("WORK.&wt",''is''); ';
|
put ' dsid=open("WORK.&wt",''is''); ';
|
||||||
put ' nlobs=attrn(dsid,''NLOBS''); ';
|
put ' nlobs=attrn(dsid,''NLOBS''); ';
|
||||||
put ' nvars=attrn(dsid,''NVARS''); ';
|
put ' nvars=attrn(dsid,''NVARS''); ';
|
||||||
@@ -7609,10 +7687,10 @@ data _null_;
|
|||||||
put ' put '',"nvars":'' nvars; ';
|
put ' put '',"nvars":'' nvars; ';
|
||||||
put ' %mp_jsonout(OBJ,&tempds,jref=&fref,dslabel=colattrs,engine=DATASTEP) ';
|
put ' %mp_jsonout(OBJ,&tempds,jref=&fref,dslabel=colattrs,engine=DATASTEP) ';
|
||||||
put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,engine=DATASTEP) ';
|
put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,engine=DATASTEP) ';
|
||||||
put ' data _null_; file &fref encoding=''utf-8''; ';
|
put ' data _null_; file &fref mod encoding=''utf-8''; ';
|
||||||
put ' put "}"; ';
|
put ' put "}"; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' data _null_; file &fref encoding=''utf-8''; ';
|
put ' data _null_; file &fref mod encoding=''utf-8''; ';
|
||||||
put ' put "}"; ';
|
put ' put "}"; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
@@ -11060,14 +11138,14 @@ run;
|
|||||||
i+1;
|
i+1;
|
||||||
call symputx('wt'!!left(i),name,'l');
|
call symputx('wt'!!left(i),name,'l');
|
||||||
call symputx('wtcnt',i,'l');
|
call symputx('wtcnt',i,'l');
|
||||||
data _null_; file &fref encoding='utf-8';
|
data _null_; file &fref mod encoding='utf-8';
|
||||||
put ",""WORK"":{";
|
put ",""WORK"":{";
|
||||||
%do i=1 %to &wtcnt;
|
%do i=1 %to &wtcnt;
|
||||||
%let wt=&&wt&i;
|
%let wt=&&wt&i;
|
||||||
proc contents noprint data=&wt
|
proc contents noprint data=&wt
|
||||||
out=_data_ (keep=name type length format:);
|
out=_data_ (keep=name type length format:);
|
||||||
run;%let tempds=%scan(&syslast,2,.);
|
run;%let tempds=%scan(&syslast,2,.);
|
||||||
data _null_; file &fref encoding='utf-8';
|
data _null_; file &fref mod encoding='utf-8';
|
||||||
dsid=open("WORK.&wt",'is');
|
dsid=open("WORK.&wt",'is');
|
||||||
nlobs=attrn(dsid,'NLOBS');
|
nlobs=attrn(dsid,'NLOBS');
|
||||||
nvars=attrn(dsid,'NVARS');
|
nvars=attrn(dsid,'NVARS');
|
||||||
@@ -11078,10 +11156,10 @@ run;
|
|||||||
put ',"nvars":' nvars;
|
put ',"nvars":' nvars;
|
||||||
%mp_jsonout(OBJ,&tempds,jref=&fref,dslabel=colattrs,engine=DATASTEP)
|
%mp_jsonout(OBJ,&tempds,jref=&fref,dslabel=colattrs,engine=DATASTEP)
|
||||||
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,engine=DATASTEP)
|
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,engine=DATASTEP)
|
||||||
data _null_; file &fref encoding='utf-8';
|
data _null_; file &fref mod encoding='utf-8';
|
||||||
put "}";
|
put "}";
|
||||||
%end;
|
%end;
|
||||||
data _null_; file &fref encoding='utf-8';
|
data _null_; file &fref mod encoding='utf-8';
|
||||||
put "}";
|
put "}";
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
@@ -11253,8 +11331,8 @@ run;
|
|||||||
|
|
||||||
@param path= The full path of the folder to be created
|
@param path= The full path of the folder to be created
|
||||||
@param access_token_var= The global macro variable to contain the access token
|
@param access_token_var= The global macro variable to contain the access token
|
||||||
@param grant_type= valid values are "password" or "authorization_code" (unquoted).
|
@param grant_type= (authorization_code) Valid values are "password" or
|
||||||
The default is authorization_code.
|
"authorization_code" (unquoted).
|
||||||
|
|
||||||
|
|
||||||
@version VIYA V.03.04
|
@version VIYA V.03.04
|
||||||
@@ -11283,7 +11361,6 @@ run;
|
|||||||
%let &access_token_var=;
|
%let &access_token_var=;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%put &sysmacroname: grant_type=&grant_type;
|
|
||||||
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
||||||
and &grant_type ne sas_services
|
and &grant_type ne sas_services
|
||||||
)
|
)
|
||||||
@@ -11329,12 +11406,15 @@ options noquotelenmax;
|
|||||||
%local libref1;
|
%local libref1;
|
||||||
%let libref1=%mf_getuniquelibref();
|
%let libref1=%mf_getuniquelibref();
|
||||||
libname &libref1 JSON fileref=&fname1;
|
libname &libref1 JSON fileref=&fname1;
|
||||||
%mp_abort(iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 404)
|
%mp_abort(
|
||||||
|
iftrue=(
|
||||||
|
&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 404
|
||||||
|
)
|
||||||
,mac=&sysmacroname
|
,mac=&sysmacroname
|
||||||
,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
|
,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
|
||||||
)
|
)
|
||||||
%if &SYS_PROCHTTP_STATUS_CODE=200 %then %do;
|
%if &SYS_PROCHTTP_STATUS_CODE=200 %then %do;
|
||||||
%put &sysmacroname &newpath exists so grab the follow on link ;
|
%*put &sysmacroname &newpath exists so grab the follow on link ;
|
||||||
data _null_;
|
data _null_;
|
||||||
set &libref1..links;
|
set &libref1..links;
|
||||||
if rel='createChild' then
|
if rel='createChild' then
|
||||||
@@ -11466,7 +11546,6 @@ https://go.documentation.sas.com/?docsetId=calcontexts&docsetTarget=n1hjn8eobk5p
|
|||||||
%let oauth_bearer=oauth_bearer=sas_services;
|
%let oauth_bearer=oauth_bearer=sas_services;
|
||||||
%let &access_token_var=;
|
%let &access_token_var=;
|
||||||
%end;
|
%end;
|
||||||
%put &sysmacroname: grant_type=&grant_type;
|
|
||||||
|
|
||||||
/* initial validation checking */
|
/* initial validation checking */
|
||||||
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
||||||
@@ -11748,9 +11827,10 @@ run;
|
|||||||
needs to be attached to the beginning of the service
|
needs to be attached to the beginning of the service
|
||||||
@param code= Fileref(s) of the actual code to be added
|
@param code= Fileref(s) of the actual code to be added
|
||||||
@param access_token_var= The global macro variable to contain the access token
|
@param access_token_var= The global macro variable to contain the access token
|
||||||
@param grant_type= valid values are "password" or "authorization_code" (unquoted).
|
@param grant_type= valid values are "password" or "authorization_code"
|
||||||
The default is authorization_code.
|
(unquoted). The default is authorization_code.
|
||||||
@param replace= select NO to avoid replacing any existing service in that location
|
@param replace= select NO to avoid replacing any existing service in that
|
||||||
|
location
|
||||||
@param adapter= the macro uses the sasjs adapter by default. To use another
|
@param adapter= the macro uses the sasjs adapter by default. To use another
|
||||||
adapter, add a (different) fileref here.
|
adapter, add a (different) fileref here.
|
||||||
@param contextname= Choose a specific context on which to run the Job. Leave
|
@param contextname= Choose a specific context on which to run the Job. Leave
|
||||||
@@ -11784,7 +11864,6 @@ https://go.documentation.sas.com/?docsetId=calcontexts&docsetTarget=n1hjn8eobk5p
|
|||||||
%let oauth_bearer=oauth_bearer=sas_services;
|
%let oauth_bearer=oauth_bearer=sas_services;
|
||||||
%let &access_token_var=;
|
%let &access_token_var=;
|
||||||
%end;
|
%end;
|
||||||
%put &sysmacroname: grant_type=&grant_type;
|
|
||||||
|
|
||||||
/* initial validation checking */
|
/* initial validation checking */
|
||||||
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
||||||
@@ -11847,7 +11926,8 @@ libname &libref1 JSON fileref=&fname1;
|
|||||||
|
|
||||||
data _null_;
|
data _null_;
|
||||||
set &libref1..links;
|
set &libref1..links;
|
||||||
if rel='members' then call symputx('membercheck',quote("&base_uri"!!trim(href)),'l');
|
if rel='members' then
|
||||||
|
call symputx('membercheck',quote("&base_uri"!!trim(href)),'l');
|
||||||
else if rel='self' then call symputx('parentFolderUri',href,'l');
|
else if rel='self' then call symputx('parentFolderUri',href,'l');
|
||||||
run;
|
run;
|
||||||
data _null_;
|
data _null_;
|
||||||
@@ -12037,7 +12117,7 @@ data _null_;
|
|||||||
put '%end; ';
|
put '%end; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put '%else %if &action=CLOSE %then %do; ';
|
put '%else %if &action=CLOSE %then %do; ';
|
||||||
put ' data _null_;file &jref encoding=''utf-8''; ';
|
put ' data _null_;file &jref encoding=''utf-8'' mod; ';
|
||||||
put ' put "}"; ';
|
put ' put "}"; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
put '%end; ';
|
put '%end; ';
|
||||||
@@ -12169,7 +12249,7 @@ data _null_;
|
|||||||
put '%end; ';
|
put '%end; ';
|
||||||
put '%else %if &action=ARR or &action=OBJ %then %do; ';
|
put '%else %if &action=ARR or &action=OBJ %then %do; ';
|
||||||
put ' %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt ';
|
put ' %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt ';
|
||||||
put ' ,jref=&fref,engine=PROCJSON,dbg=%str(&_debug) ';
|
put ' ,jref=&fref,engine=DATASTEP,dbg=%str(&_debug) ';
|
||||||
put ' ) ';
|
put ' ) ';
|
||||||
put '%end; ';
|
put '%end; ';
|
||||||
put '%else %if &action=CLOSE %then %do; ';
|
put '%else %if &action=CLOSE %then %do; ';
|
||||||
@@ -12294,6 +12374,14 @@ run;
|
|||||||
rc =fput(fileid,'\');rc =fwrite(fileid);
|
rc =fput(fileid,'\');rc =fwrite(fileid);
|
||||||
rc =fput(fileid,'\');rc =fwrite(fileid);
|
rc =fput(fileid,'\');rc =fwrite(fileid);
|
||||||
end;
|
end;
|
||||||
|
else if rec='01'x then do; /* Unprintable */
|
||||||
|
rc =fput(fileid,'\');rc =fwrite(fileid);
|
||||||
|
rc =fput(fileid,'u');rc =fwrite(fileid);
|
||||||
|
rc =fput(fileid,'0');rc =fwrite(fileid);
|
||||||
|
rc =fput(fileid,'0');rc =fwrite(fileid);
|
||||||
|
rc =fput(fileid,'0');rc =fwrite(fileid);
|
||||||
|
rc =fput(fileid,'1');rc =fwrite(fileid);
|
||||||
|
end;
|
||||||
else do;
|
else do;
|
||||||
rc =fput(fileid,rec);
|
rc =fput(fileid,rec);
|
||||||
rc =fwrite(fileid);
|
rc =fwrite(fileid);
|
||||||
@@ -12559,7 +12647,7 @@ libname &libref1a clear;
|
|||||||
%let oauth_bearer=oauth_bearer=sas_services;
|
%let oauth_bearer=oauth_bearer=sas_services;
|
||||||
%let &access_token_var=;
|
%let &access_token_var=;
|
||||||
%end;
|
%end;
|
||||||
%put &sysmacroname: grant_type=&grant_type;
|
|
||||||
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
||||||
and &grant_type ne sas_services
|
and &grant_type ne sas_services
|
||||||
)
|
)
|
||||||
@@ -12701,7 +12789,7 @@ libname &libref1a clear;
|
|||||||
%let oauth_bearer=oauth_bearer=sas_services;
|
%let oauth_bearer=oauth_bearer=sas_services;
|
||||||
%let &access_token_var=;
|
%let &access_token_var=;
|
||||||
%end;
|
%end;
|
||||||
%put &sysmacroname: grant_type=&grant_type;
|
|
||||||
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
||||||
and &grant_type ne sas_services
|
and &grant_type ne sas_services
|
||||||
)
|
)
|
||||||
@@ -13127,7 +13215,7 @@ libname &libref1 clear;
|
|||||||
%let oauth_bearer=oauth_bearer=sas_services;
|
%let oauth_bearer=oauth_bearer=sas_services;
|
||||||
%let &access_token_var=;
|
%let &access_token_var=;
|
||||||
%end;
|
%end;
|
||||||
%put &sysmacroname: grant_type=&grant_type;
|
|
||||||
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
||||||
and &grant_type ne sas_services
|
and &grant_type ne sas_services
|
||||||
)
|
)
|
||||||
@@ -15376,7 +15464,7 @@ libname &libref clear;
|
|||||||
filename &fref1 clear;
|
filename &fref1 clear;
|
||||||
|
|
||||||
%mend;/**
|
%mend;/**
|
||||||
@file mv_webout.sas
|
@file
|
||||||
@brief Send data to/from the SAS Viya Job Execution Service
|
@brief Send data to/from the SAS Viya Job Execution Service
|
||||||
@details This macro should be added to the start of each Job Execution
|
@details This macro should be added to the start of each Job Execution
|
||||||
Service, **immediately** followed by a call to:
|
Service, **immediately** followed by a call to:
|
||||||
@@ -15388,7 +15476,7 @@ filename &fref1 clear;
|
|||||||
following syntax:
|
following syntax:
|
||||||
|
|
||||||
data some datasets; * make some data ;
|
data some datasets; * make some data ;
|
||||||
retain some columns;
|
retain some columns;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
%mv_webout(OPEN)
|
%mv_webout(OPEN)
|
||||||
@@ -15539,7 +15627,7 @@ filename &fref1 clear;
|
|||||||
%end;
|
%end;
|
||||||
%else %if &action=ARR or &action=OBJ %then %do;
|
%else %if &action=ARR or &action=OBJ %then %do;
|
||||||
%mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt
|
%mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt
|
||||||
,jref=&fref,engine=PROCJSON,dbg=%str(&_debug)
|
,jref=&fref,engine=DATASTEP,dbg=%str(&_debug)
|
||||||
)
|
)
|
||||||
%end;
|
%end;
|
||||||
%else %if &action=CLOSE %then %do;
|
%else %if &action=CLOSE %then %do;
|
||||||
|
|||||||
@@ -22,6 +22,9 @@
|
|||||||
@version 9.2
|
@version 9.2
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
|
|
||||||
|
<h4> Related Macros </h4>
|
||||||
|
@li mf_getxengine.sas
|
||||||
|
|
||||||
**/
|
**/
|
||||||
/** @cond */
|
/** @cond */
|
||||||
|
|
||||||
|
|||||||
43
base/mf_getxengine.sas
Normal file
43
base/mf_getxengine.sas
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Returns the engine type of a SAS fileref
|
||||||
|
@details Queries sashelp.vextfl to get the xengine value.
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
filename feng temp;
|
||||||
|
%put %mf_getxengine(feng);
|
||||||
|
|
||||||
|
returns:
|
||||||
|
> TEMP
|
||||||
|
|
||||||
|
@param fref The fileref to check
|
||||||
|
|
||||||
|
@returns The XENGINE value in sashelp.vextfl or 0 if not found.
|
||||||
|
|
||||||
|
@version 9.2
|
||||||
|
@author Allan Bowe
|
||||||
|
|
||||||
|
<h4> Related Macros </h4>
|
||||||
|
@li mf_getengine.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mf_getxengine(fref
|
||||||
|
)/*/STORE SOURCE*/;
|
||||||
|
%local dsid engnum rc engine;
|
||||||
|
|
||||||
|
%let dsid=%sysfunc(
|
||||||
|
open(sashelp.vextfl(where=(fileref="%upcase(&fref)")),i)
|
||||||
|
);
|
||||||
|
%if (&dsid ^= 0) %then %do;
|
||||||
|
%let engnum=%sysfunc(varnum(&dsid,XENGINE));
|
||||||
|
%let rc=%sysfunc(fetch(&dsid));
|
||||||
|
%let engine=%sysfunc(getvarc(&dsid,&engnum));
|
||||||
|
%* put &fref. ENGINE is &engine.;
|
||||||
|
%let rc= %sysfunc(close(&dsid));
|
||||||
|
%end;
|
||||||
|
%else %let engine=0;
|
||||||
|
|
||||||
|
&engine
|
||||||
|
|
||||||
|
%mend;
|
||||||
75
base/mp_hashdataset.sas
Normal file
75
base/mp_hashdataset.sas
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Returns a unique hash for a dataset
|
||||||
|
@details Ignores metadata attributes, used only to hash values. Compared
|
||||||
|
datasets must be in the same order.
|
||||||
|
|
||||||
|
%mp_hashdataset(sashelp.class,outds=myhash)
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
set work.myhash;
|
||||||
|
put hashkey=;
|
||||||
|
run;
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_getattrn.sas
|
||||||
|
@li mf_getuniquename.sas
|
||||||
|
@li mf_getvarlist.sas
|
||||||
|
@li mf_getvartype.sas
|
||||||
|
|
||||||
|
@param [in] libds dataset to hash
|
||||||
|
@param [out] outds= (work.mf_hashdataset) The output dataset to create. This
|
||||||
|
will contain one column (hashkey) with one observation (a hex32.
|
||||||
|
representation of the input hash)
|
||||||
|
|hashkey:$32.|
|
||||||
|
|---|
|
||||||
|
|28ABC74ABFC45F50794237BA5566E6CA|
|
||||||
|
|
||||||
|
@version 9.2
|
||||||
|
@author Allan Bowe
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mp_hashdataset(
|
||||||
|
libds,
|
||||||
|
outds=
|
||||||
|
)/*/STORE SOURCE*/;
|
||||||
|
%if %mf_getattrn(&libds,NLOBS)=0 %then %do;
|
||||||
|
%put %str(WARN)ING: Dataset &libds is empty;, or is not a dataset;
|
||||||
|
%end;
|
||||||
|
%else %if %mf_getattrn(&libds,NLOBS)<0 %then %do;
|
||||||
|
%put %str(ERR)OR: Dataset &libds is not a dataset;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
%local keyvar /* roll up the md5 */
|
||||||
|
prevkeyvar /* retain prev record md5 */
|
||||||
|
lastvar /* last var in input ds */
|
||||||
|
varlist var i;
|
||||||
|
/* avoid naming conflict for hash key vars */
|
||||||
|
%let keyvar=%mf_getuniquename();
|
||||||
|
%let prevkeyvar=%mf_getuniquename();
|
||||||
|
%let lastvar=%mf_getuniquename();
|
||||||
|
%let varlist=%mf_getvarlist(&libds);
|
||||||
|
data &outds(rename=(&keyvar=hashkey) keep=&keyvar);
|
||||||
|
length &prevkeyvar &keyvar $32;
|
||||||
|
retain &prevkeyvar;
|
||||||
|
set &libds end=&lastvar;
|
||||||
|
/* hash should include previous row */
|
||||||
|
if _n_>1 then &keyvar=put(md5(&prevkeyvar
|
||||||
|
/* loop every column, hashing every individual value */
|
||||||
|
%do i=1 %to %sysfunc(countw(&varlist));
|
||||||
|
%let var=%scan(&varlist,&i,%str( ));
|
||||||
|
%if %mf_getvartype(&libds,&var)=C %then %do;
|
||||||
|
!!put(md5(trim(&var)),$hex32.)
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
!!put(md5(trim(put(&var*1,binary64.))),$hex32.)
|
||||||
|
%end;
|
||||||
|
%end;
|
||||||
|
),$hex32.);
|
||||||
|
&prevkeyvar=&keyvar;
|
||||||
|
if &lastvar then output;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%mend;
|
||||||
@@ -4,8 +4,11 @@
|
|||||||
@details PROC JSON is faster but will produce errs like the ones below if
|
@details PROC JSON is faster but will produce errs like the ones below if
|
||||||
special chars are encountered.
|
special chars are encountered.
|
||||||
|
|
||||||
>An object or array close is not valid at this point in the JSON text.
|
> ERROR: Some code points did not transcode.
|
||||||
>Date value out of range
|
|
||||||
|
> An object or array close is not valid at this point in the JSON text.
|
||||||
|
|
||||||
|
> Date value out of range
|
||||||
|
|
||||||
If this happens, try running with ENGINE=DATASTEP.
|
If this happens, try running with ENGINE=DATASTEP.
|
||||||
|
|
||||||
@@ -14,7 +17,9 @@
|
|||||||
filename tmp temp;
|
filename tmp temp;
|
||||||
data class; set sashelp.class;run;
|
data class; set sashelp.class;run;
|
||||||
|
|
||||||
|
%mp_jsonout(OPEN,jref=tmp)
|
||||||
%mp_jsonout(OBJ,class,jref=tmp)
|
%mp_jsonout(OBJ,class,jref=tmp)
|
||||||
|
%mp_jsonout(CLOSE,jref=tmp)
|
||||||
|
|
||||||
data _null_;
|
data _null_;
|
||||||
infile tmp;
|
infile tmp;
|
||||||
@@ -27,18 +32,18 @@
|
|||||||
For more information see https://sasjs.io
|
For more information see https://sasjs.io
|
||||||
|
|
||||||
@param action Valid values:
|
@param action Valid values:
|
||||||
* OPEN - opens the JSON
|
@li OPEN - opens the JSON
|
||||||
* OBJ - sends a table with each row as an object
|
@li OBJ - sends a table with each row as an object
|
||||||
* ARR - sends a table with each row in an array
|
@li ARR - sends a table with each row in an array
|
||||||
* CLOSE - closes the JSON
|
@li CLOSE - closes the JSON
|
||||||
|
|
||||||
@param ds the dataset to send. Must be a work table.
|
@param ds the dataset to send. Must be a work table.
|
||||||
@param jref= the fileref to which to send the JSON
|
@param jref= the fileref to which to send the JSON
|
||||||
@param dslabel= the name to give the table in the exported JSON
|
@param dslabel= the name to give the table in the exported JSON
|
||||||
@param fmt= Whether to keep or strip formats from the table
|
@param fmt= Whether to keep or strip formats from the table
|
||||||
@param engine= Which engine to use to send the JSON, options are:
|
@param engine= Which engine to use to send the JSON, valid options are:
|
||||||
* PROCJSON (default)
|
@li PROCJSON (default)
|
||||||
* DATASTEP
|
@li DATASTEP (more reliable when data has non standard characters)
|
||||||
|
|
||||||
@param dbg= DEPRECATED - was used to conditionally add PRETTY to
|
@param dbg= DEPRECATED - was used to conditionally add PRETTY to
|
||||||
proc json but this can cause line truncation in large files.
|
proc json but this can cause line truncation in large files.
|
||||||
@@ -160,8 +165,8 @@
|
|||||||
%end;
|
%end;
|
||||||
|
|
||||||
%else %if &action=CLOSE %then %do;
|
%else %if &action=CLOSE %then %do;
|
||||||
data _null_;file &jref encoding='utf-8';
|
data _null_;file &jref encoding='utf-8' mod;
|
||||||
put "}";
|
put "}";
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
%mend;
|
%mend;
|
||||||
|
|||||||
@@ -376,8 +376,6 @@ run;
|
|||||||
*/
|
*/
|
||||||
%mm_updatestpsourcecode(stp=&tree/&stpname
|
%mm_updatestpsourcecode(stp=&tree/&stpname
|
||||||
,stpcode="&directory/&filename"
|
,stpcode="&directory/&filename"
|
||||||
,frefin=&frefin.
|
|
||||||
,frefout=&frefout.
|
|
||||||
,mdebug=&mdebug
|
,mdebug=&mdebug
|
||||||
,minify=&minify)
|
,minify=&minify)
|
||||||
|
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ data _null_;
|
|||||||
put '%end; ';
|
put '%end; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put '%else %if &action=CLOSE %then %do; ';
|
put '%else %if &action=CLOSE %then %do; ';
|
||||||
put ' data _null_;file &jref encoding=''utf-8''; ';
|
put ' data _null_;file &jref encoding=''utf-8'' mod; ';
|
||||||
put ' put "}"; ';
|
put ' put "}"; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
put '%end; ';
|
put '%end; ';
|
||||||
@@ -277,14 +277,14 @@ data _null_;
|
|||||||
put ' i+1; ';
|
put ' i+1; ';
|
||||||
put ' call symputx(''wt''!!left(i),name,''l''); ';
|
put ' call symputx(''wt''!!left(i),name,''l''); ';
|
||||||
put ' call symputx(''wtcnt'',i,''l''); ';
|
put ' call symputx(''wtcnt'',i,''l''); ';
|
||||||
put ' data _null_; file &fref encoding=''utf-8''; ';
|
put ' data _null_; file &fref mod encoding=''utf-8''; ';
|
||||||
put ' put ",""WORK"":{"; ';
|
put ' put ",""WORK"":{"; ';
|
||||||
put ' %do i=1 %to &wtcnt; ';
|
put ' %do i=1 %to &wtcnt; ';
|
||||||
put ' %let wt=&&wt&i; ';
|
put ' %let wt=&&wt&i; ';
|
||||||
put ' proc contents noprint data=&wt ';
|
put ' proc contents noprint data=&wt ';
|
||||||
put ' out=_data_ (keep=name type length format:); ';
|
put ' out=_data_ (keep=name type length format:); ';
|
||||||
put ' run;%let tempds=%scan(&syslast,2,.); ';
|
put ' run;%let tempds=%scan(&syslast,2,.); ';
|
||||||
put ' data _null_; file &fref encoding=''utf-8''; ';
|
put ' data _null_; file &fref mod encoding=''utf-8''; ';
|
||||||
put ' dsid=open("WORK.&wt",''is''); ';
|
put ' dsid=open("WORK.&wt",''is''); ';
|
||||||
put ' nlobs=attrn(dsid,''NLOBS''); ';
|
put ' nlobs=attrn(dsid,''NLOBS''); ';
|
||||||
put ' nvars=attrn(dsid,''NVARS''); ';
|
put ' nvars=attrn(dsid,''NVARS''); ';
|
||||||
@@ -295,10 +295,10 @@ data _null_;
|
|||||||
put ' put '',"nvars":'' nvars; ';
|
put ' put '',"nvars":'' nvars; ';
|
||||||
put ' %mp_jsonout(OBJ,&tempds,jref=&fref,dslabel=colattrs,engine=DATASTEP) ';
|
put ' %mp_jsonout(OBJ,&tempds,jref=&fref,dslabel=colattrs,engine=DATASTEP) ';
|
||||||
put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,engine=DATASTEP) ';
|
put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,engine=DATASTEP) ';
|
||||||
put ' data _null_; file &fref encoding=''utf-8''; ';
|
put ' data _null_; file &fref mod encoding=''utf-8''; ';
|
||||||
put ' put "}"; ';
|
put ' put "}"; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' data _null_; file &fref encoding=''utf-8''; ';
|
put ' data _null_; file &fref mod encoding=''utf-8''; ';
|
||||||
put ' put "}"; ';
|
put ' put "}"; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
|
|||||||
@@ -108,14 +108,14 @@
|
|||||||
i+1;
|
i+1;
|
||||||
call symputx('wt'!!left(i),name,'l');
|
call symputx('wt'!!left(i),name,'l');
|
||||||
call symputx('wtcnt',i,'l');
|
call symputx('wtcnt',i,'l');
|
||||||
data _null_; file &fref encoding='utf-8';
|
data _null_; file &fref mod encoding='utf-8';
|
||||||
put ",""WORK"":{";
|
put ",""WORK"":{";
|
||||||
%do i=1 %to &wtcnt;
|
%do i=1 %to &wtcnt;
|
||||||
%let wt=&&wt&i;
|
%let wt=&&wt&i;
|
||||||
proc contents noprint data=&wt
|
proc contents noprint data=&wt
|
||||||
out=_data_ (keep=name type length format:);
|
out=_data_ (keep=name type length format:);
|
||||||
run;%let tempds=%scan(&syslast,2,.);
|
run;%let tempds=%scan(&syslast,2,.);
|
||||||
data _null_; file &fref encoding='utf-8';
|
data _null_; file &fref mod encoding='utf-8';
|
||||||
dsid=open("WORK.&wt",'is');
|
dsid=open("WORK.&wt",'is');
|
||||||
nlobs=attrn(dsid,'NLOBS');
|
nlobs=attrn(dsid,'NLOBS');
|
||||||
nvars=attrn(dsid,'NVARS');
|
nvars=attrn(dsid,'NVARS');
|
||||||
@@ -126,10 +126,10 @@
|
|||||||
put ',"nvars":' nvars;
|
put ',"nvars":' nvars;
|
||||||
%mp_jsonout(OBJ,&tempds,jref=&fref,dslabel=colattrs,engine=DATASTEP)
|
%mp_jsonout(OBJ,&tempds,jref=&fref,dslabel=colattrs,engine=DATASTEP)
|
||||||
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,engine=DATASTEP)
|
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,engine=DATASTEP)
|
||||||
data _null_; file &fref encoding='utf-8';
|
data _null_; file &fref mod encoding='utf-8';
|
||||||
put "}";
|
put "}";
|
||||||
%end;
|
%end;
|
||||||
data _null_; file &fref encoding='utf-8';
|
data _null_; file &fref mod encoding='utf-8';
|
||||||
put "}";
|
put "}";
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://cli.sasjs.io/sasjsconfig-schema.json",
|
"$schema": "https://cli.sasjs.io/sasjsconfig-schema.json",
|
||||||
"macroFolders": ["base", "meta", "metax", "viya", "lua"],
|
"macroFolders": ["base", "meta", "metax", "viya", "lua"],
|
||||||
"docConfig":{
|
"docConfig": {
|
||||||
"displayMacroCore": false,
|
"displayMacroCore": false,
|
||||||
"enableLineage": false,
|
"enableLineage": false,
|
||||||
"doxyContent": {
|
"doxyContent": {
|
||||||
@@ -9,5 +9,26 @@
|
|||||||
"logo": "Macro_core_website_1.png",
|
"logo": "Macro_core_website_1.png",
|
||||||
"readMe": "../../README.md"
|
"readMe": "../../README.md"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"serviceConfig": {
|
||||||
|
"initProgram": "tests/testinit.sas"
|
||||||
|
},
|
||||||
|
"defaultTarget": "viya",
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"name": "viya",
|
||||||
|
"serverUrl": "https://sas.analytium.co.uk",
|
||||||
|
"serverType": "SASVIYA",
|
||||||
|
"appLoc": "/Public/temp/macrocore",
|
||||||
|
"serviceConfig": {
|
||||||
|
"serviceFolders": ["tests/viya"],
|
||||||
|
"macroVars": {
|
||||||
|
"mcTestAppLoc": "/Public/temp/macrocore"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deployConfig": {
|
||||||
|
"deployServicePack": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
8
tests/testinit.sas
Normal file
8
tests/testinit.sas
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief init file for tests
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
/* location in metadata or SAS Drive for temporary files */
|
||||||
|
%let mcTestAppLoc=/Public/temp/test;
|
||||||
24
tests/viya/mv_createwebservice.test.sas
Normal file
24
tests/viya/mv_createwebservice.test.sas
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Testing mv_createwebservice macro
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mv_createwebservice.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test Case 1
|
||||||
|
* Send special char in a service
|
||||||
|
*/
|
||||||
|
|
||||||
|
filename testref temp;
|
||||||
|
data _null_;
|
||||||
|
file testref;
|
||||||
|
put '01'x;
|
||||||
|
run;
|
||||||
|
%mv_createwebservice(
|
||||||
|
path=&mcTestAppLoc/tests/macros,
|
||||||
|
code=testref,
|
||||||
|
name=mv_createwebservice
|
||||||
|
)
|
||||||
@@ -9,8 +9,8 @@
|
|||||||
|
|
||||||
@param path= The full path of the folder to be created
|
@param path= The full path of the folder to be created
|
||||||
@param access_token_var= The global macro variable to contain the access token
|
@param access_token_var= The global macro variable to contain the access token
|
||||||
@param grant_type= valid values are "password" or "authorization_code" (unquoted).
|
@param grant_type= (authorization_code) Valid values are "password" or
|
||||||
The default is authorization_code.
|
"authorization_code" (unquoted).
|
||||||
|
|
||||||
|
|
||||||
@version VIYA V.03.04
|
@version VIYA V.03.04
|
||||||
@@ -39,7 +39,6 @@
|
|||||||
%let &access_token_var=;
|
%let &access_token_var=;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%put &sysmacroname: grant_type=&grant_type;
|
|
||||||
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
||||||
and &grant_type ne sas_services
|
and &grant_type ne sas_services
|
||||||
)
|
)
|
||||||
@@ -85,12 +84,15 @@ options noquotelenmax;
|
|||||||
%local libref1;
|
%local libref1;
|
||||||
%let libref1=%mf_getuniquelibref();
|
%let libref1=%mf_getuniquelibref();
|
||||||
libname &libref1 JSON fileref=&fname1;
|
libname &libref1 JSON fileref=&fname1;
|
||||||
%mp_abort(iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 404)
|
%mp_abort(
|
||||||
|
iftrue=(
|
||||||
|
&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 404
|
||||||
|
)
|
||||||
,mac=&sysmacroname
|
,mac=&sysmacroname
|
||||||
,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
|
,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
|
||||||
)
|
)
|
||||||
%if &SYS_PROCHTTP_STATUS_CODE=200 %then %do;
|
%if &SYS_PROCHTTP_STATUS_CODE=200 %then %do;
|
||||||
%put &sysmacroname &newpath exists so grab the follow on link ;
|
%*put &sysmacroname &newpath exists so grab the follow on link ;
|
||||||
data _null_;
|
data _null_;
|
||||||
set &libref1..links;
|
set &libref1..links;
|
||||||
if rel='createChild' then
|
if rel='createChild' then
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ https://go.documentation.sas.com/?docsetId=calcontexts&docsetTarget=n1hjn8eobk5p
|
|||||||
%let oauth_bearer=oauth_bearer=sas_services;
|
%let oauth_bearer=oauth_bearer=sas_services;
|
||||||
%let &access_token_var=;
|
%let &access_token_var=;
|
||||||
%end;
|
%end;
|
||||||
%put &sysmacroname: grant_type=&grant_type;
|
|
||||||
|
|
||||||
/* initial validation checking */
|
/* initial validation checking */
|
||||||
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
||||||
|
|||||||
@@ -46,9 +46,10 @@
|
|||||||
needs to be attached to the beginning of the service
|
needs to be attached to the beginning of the service
|
||||||
@param code= Fileref(s) of the actual code to be added
|
@param code= Fileref(s) of the actual code to be added
|
||||||
@param access_token_var= The global macro variable to contain the access token
|
@param access_token_var= The global macro variable to contain the access token
|
||||||
@param grant_type= valid values are "password" or "authorization_code" (unquoted).
|
@param grant_type= valid values are "password" or "authorization_code"
|
||||||
The default is authorization_code.
|
(unquoted). The default is authorization_code.
|
||||||
@param replace= select NO to avoid replacing any existing service in that location
|
@param replace= select NO to avoid replacing any existing service in that
|
||||||
|
location
|
||||||
@param adapter= the macro uses the sasjs adapter by default. To use another
|
@param adapter= the macro uses the sasjs adapter by default. To use another
|
||||||
adapter, add a (different) fileref here.
|
adapter, add a (different) fileref here.
|
||||||
@param contextname= Choose a specific context on which to run the Job. Leave
|
@param contextname= Choose a specific context on which to run the Job. Leave
|
||||||
@@ -82,7 +83,6 @@ https://go.documentation.sas.com/?docsetId=calcontexts&docsetTarget=n1hjn8eobk5p
|
|||||||
%let oauth_bearer=oauth_bearer=sas_services;
|
%let oauth_bearer=oauth_bearer=sas_services;
|
||||||
%let &access_token_var=;
|
%let &access_token_var=;
|
||||||
%end;
|
%end;
|
||||||
%put &sysmacroname: grant_type=&grant_type;
|
|
||||||
|
|
||||||
/* initial validation checking */
|
/* initial validation checking */
|
||||||
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
||||||
@@ -145,7 +145,8 @@ libname &libref1 JSON fileref=&fname1;
|
|||||||
|
|
||||||
data _null_;
|
data _null_;
|
||||||
set &libref1..links;
|
set &libref1..links;
|
||||||
if rel='members' then call symputx('membercheck',quote("&base_uri"!!trim(href)),'l');
|
if rel='members' then
|
||||||
|
call symputx('membercheck',quote("&base_uri"!!trim(href)),'l');
|
||||||
else if rel='self' then call symputx('parentFolderUri',href,'l');
|
else if rel='self' then call symputx('parentFolderUri',href,'l');
|
||||||
run;
|
run;
|
||||||
data _null_;
|
data _null_;
|
||||||
@@ -335,7 +336,7 @@ data _null_;
|
|||||||
put '%end; ';
|
put '%end; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put '%else %if &action=CLOSE %then %do; ';
|
put '%else %if &action=CLOSE %then %do; ';
|
||||||
put ' data _null_;file &jref encoding=''utf-8''; ';
|
put ' data _null_;file &jref encoding=''utf-8'' mod; ';
|
||||||
put ' put "}"; ';
|
put ' put "}"; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
put '%end; ';
|
put '%end; ';
|
||||||
@@ -467,7 +468,7 @@ data _null_;
|
|||||||
put '%end; ';
|
put '%end; ';
|
||||||
put '%else %if &action=ARR or &action=OBJ %then %do; ';
|
put '%else %if &action=ARR or &action=OBJ %then %do; ';
|
||||||
put ' %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt ';
|
put ' %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt ';
|
||||||
put ' ,jref=&fref,engine=PROCJSON,dbg=%str(&_debug) ';
|
put ' ,jref=&fref,engine=DATASTEP,dbg=%str(&_debug) ';
|
||||||
put ' ) ';
|
put ' ) ';
|
||||||
put '%end; ';
|
put '%end; ';
|
||||||
put '%else %if &action=CLOSE %then %do; ';
|
put '%else %if &action=CLOSE %then %do; ';
|
||||||
@@ -592,6 +593,14 @@ run;
|
|||||||
rc =fput(fileid,'\');rc =fwrite(fileid);
|
rc =fput(fileid,'\');rc =fwrite(fileid);
|
||||||
rc =fput(fileid,'\');rc =fwrite(fileid);
|
rc =fput(fileid,'\');rc =fwrite(fileid);
|
||||||
end;
|
end;
|
||||||
|
else if rec='01'x then do; /* Unprintable */
|
||||||
|
rc =fput(fileid,'\');rc =fwrite(fileid);
|
||||||
|
rc =fput(fileid,'u');rc =fwrite(fileid);
|
||||||
|
rc =fput(fileid,'0');rc =fwrite(fileid);
|
||||||
|
rc =fput(fileid,'0');rc =fwrite(fileid);
|
||||||
|
rc =fput(fileid,'0');rc =fwrite(fileid);
|
||||||
|
rc =fput(fileid,'1');rc =fwrite(fileid);
|
||||||
|
end;
|
||||||
else do;
|
else do;
|
||||||
rc =fput(fileid,rec);
|
rc =fput(fileid,rec);
|
||||||
rc =fwrite(fileid);
|
rc =fwrite(fileid);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
%let oauth_bearer=oauth_bearer=sas_services;
|
%let oauth_bearer=oauth_bearer=sas_services;
|
||||||
%let &access_token_var=;
|
%let &access_token_var=;
|
||||||
%end;
|
%end;
|
||||||
%put &sysmacroname: grant_type=&grant_type;
|
|
||||||
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
||||||
and &grant_type ne sas_services
|
and &grant_type ne sas_services
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
%let oauth_bearer=oauth_bearer=sas_services;
|
%let oauth_bearer=oauth_bearer=sas_services;
|
||||||
%let &access_token_var=;
|
%let &access_token_var=;
|
||||||
%end;
|
%end;
|
||||||
%put &sysmacroname: grant_type=&grant_type;
|
|
||||||
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
||||||
and &grant_type ne sas_services
|
and &grant_type ne sas_services
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
%let oauth_bearer=oauth_bearer=sas_services;
|
%let oauth_bearer=oauth_bearer=sas_services;
|
||||||
%let &access_token_var=;
|
%let &access_token_var=;
|
||||||
%end;
|
%end;
|
||||||
%put &sysmacroname: grant_type=&grant_type;
|
|
||||||
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
|
||||||
and &grant_type ne sas_services
|
and &grant_type ne sas_services
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
@file mv_webout.sas
|
@file
|
||||||
@brief Send data to/from the SAS Viya Job Execution Service
|
@brief Send data to/from the SAS Viya Job Execution Service
|
||||||
@details This macro should be added to the start of each Job Execution
|
@details This macro should be added to the start of each Job Execution
|
||||||
Service, **immediately** followed by a call to:
|
Service, **immediately** followed by a call to:
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
following syntax:
|
following syntax:
|
||||||
|
|
||||||
data some datasets; * make some data ;
|
data some datasets; * make some data ;
|
||||||
retain some columns;
|
retain some columns;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
%mv_webout(OPEN)
|
%mv_webout(OPEN)
|
||||||
@@ -162,7 +162,7 @@
|
|||||||
%end;
|
%end;
|
||||||
%else %if &action=ARR or &action=OBJ %then %do;
|
%else %if &action=ARR or &action=OBJ %then %do;
|
||||||
%mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt
|
%mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt
|
||||||
,jref=&fref,engine=PROCJSON,dbg=%str(&_debug)
|
,jref=&fref,engine=DATASTEP,dbg=%str(&_debug)
|
||||||
)
|
)
|
||||||
%end;
|
%end;
|
||||||
%else %if &action=CLOSE %then %do;
|
%else %if &action=CLOSE %then %do;
|
||||||
|
|||||||
Reference in New Issue
Block a user