mirror of
https://github.com/sasjs/core.git
synced 2026-01-05 00:20:05 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f301899269 | ||
|
|
fc81f62d2f | ||
|
|
93aea5ed02 | ||
|
|
55d4c7238a | ||
|
|
cd75bf263a | ||
|
|
929a1a9974 | ||
|
|
7cafb4fb36 | ||
|
|
a8d222a0f8 | ||
|
|
ac0ddf38b0 | ||
|
|
ecd389c935 |
181
all.sas
181
all.sas
@@ -1678,6 +1678,7 @@ Usage:
|
|||||||
sysuserid=symget('sysuserid');
|
sysuserid=symget('sysuserid');
|
||||||
iftrue=symget('iftrue');
|
iftrue=symget('iftrue');
|
||||||
put (_all_)(/=);
|
put (_all_)(/=);
|
||||||
|
call symputx('syscc',0);
|
||||||
abort cancel nolist;
|
abort cancel nolist;
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
@@ -2172,6 +2173,128 @@ Usage:
|
|||||||
drop table &ds;
|
drop table &ds;
|
||||||
|
|
||||||
%mend mp_assertdsobs;/**
|
%mend mp_assertdsobs;/**
|
||||||
|
@file
|
||||||
|
@brief Convert a file to/from base64 format
|
||||||
|
@details Creates a new version of a file either encoded or decoded using
|
||||||
|
Base64. Inspired by this post by Michael Dixon:
|
||||||
|
https://support.selerity.com.au/hc/en-us/articles/223345708-Tip-SAS-and-Base64
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
filename tmp temp;
|
||||||
|
data _null_;
|
||||||
|
file tmp;
|
||||||
|
put 'base ik ally';
|
||||||
|
run;
|
||||||
|
%mp_base64copy(inref=tmp, outref=myref, action=ENCODE)
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
infile myref;
|
||||||
|
input;
|
||||||
|
put _infile_;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_base64copy(inref=myref, outref=mynewref, action=DECODE)
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
infile mynewref;
|
||||||
|
input;
|
||||||
|
put _infile_;
|
||||||
|
run;
|
||||||
|
|
||||||
|
@param [in] inref= Fileref of the input file (should exist)
|
||||||
|
@param [out] outref= Output fileref. If it does not exist, it is created.
|
||||||
|
@param [in] action= (ENCODE) The action to take. Valid values:
|
||||||
|
@li ENCODE - Convert the file to base64 format
|
||||||
|
@li DECODE - Decode the file from base64 format
|
||||||
|
|
||||||
|
@version 9.2
|
||||||
|
@author Allan Bowe, source: https://github.com/sasjs/core
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mp_abort.sas
|
||||||
|
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mp_base64copy(
|
||||||
|
inref=0,
|
||||||
|
outref=0,
|
||||||
|
action=ENCODE
|
||||||
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
|
%let inref=%upcase(&inref);
|
||||||
|
%let outref=%upcase(&outref);
|
||||||
|
%let action=%upcase(&action);
|
||||||
|
%local infound outfound;
|
||||||
|
%let infound=0;
|
||||||
|
%let outfound=0;
|
||||||
|
data _null_;
|
||||||
|
set sashelp.vextfl(where=(fileref="&inref" or fileref="&outref"));
|
||||||
|
if fileref="&inref" then call symputx('infound',1,'l');
|
||||||
|
if fileref="&outref" then call symputx('outfound',1,'l');
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_abort(iftrue= (&infound=0)
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(INREF &inref NOT FOUND!)
|
||||||
|
)
|
||||||
|
%mp_abort(iftrue= (&outref=0)
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(OUTREF NOT PROVIDED!)
|
||||||
|
)
|
||||||
|
%mp_abort(iftrue= (&action ne ENCODE and &action ne DECODE)
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(Invalid action! Should be ENCODE OR DECODE)
|
||||||
|
)
|
||||||
|
|
||||||
|
%if &outfound=0 %then %do;
|
||||||
|
filename &outref temp lrecl=2097088;
|
||||||
|
%%end;
|
||||||
|
|
||||||
|
%if &action=ENCODE %then %do;
|
||||||
|
data _null_;
|
||||||
|
length b64 $ 76 line $ 57;
|
||||||
|
retain line "";
|
||||||
|
infile &inref recfm=F lrecl= 1 end=eof;
|
||||||
|
input @1 stream $char1.;
|
||||||
|
file &outref lrecl=76;
|
||||||
|
substr(line,(_N_-(CEIL(_N_/57)-1)*57),1) = byte(rank(stream));
|
||||||
|
if mod(_N_,57)=0 or EOF then do;
|
||||||
|
if eof then b64=put(trim(line),$base64X76.);
|
||||||
|
else b64=put(line, $base64X76.);
|
||||||
|
put b64;
|
||||||
|
line="";
|
||||||
|
end;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %if &action=DECODE %then %do;
|
||||||
|
data _null_;
|
||||||
|
length filein 8 fileout 8;
|
||||||
|
filein = fopen("&inref",'I',4,'B');
|
||||||
|
fileout = fopen("&outref",'O',3,'B');
|
||||||
|
char= '20'x;
|
||||||
|
do while(fread(filein)=0);
|
||||||
|
raw="1234";
|
||||||
|
do i=1 to 4;
|
||||||
|
rc=fget(filein,char,1);
|
||||||
|
substr(raw,i,1)=char;
|
||||||
|
end;
|
||||||
|
val="123";
|
||||||
|
val=input(raw,$base64X4.);
|
||||||
|
do i=1 to 3;
|
||||||
|
length byte $1;
|
||||||
|
byte=byte(rank(substr(val,i,1)));
|
||||||
|
rc = fput(fileout, byte);
|
||||||
|
end;
|
||||||
|
rc =fwrite(fileout);
|
||||||
|
end;
|
||||||
|
rc = fclose(filein);
|
||||||
|
rc = fclose(fileout);
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
%mend mp_base64copy;/**
|
||||||
@file
|
@file
|
||||||
@brief Copy any file using binary input / output streams
|
@brief Copy any file using binary input / output streams
|
||||||
@details Reads in a file byte by byte and writes it back out. Is an
|
@details Reads in a file byte by byte and writes it back out. Is an
|
||||||
@@ -6241,8 +6364,11 @@ libname &lib clear;
|
|||||||
|mustbevalidname|can be anything, oops, %abort!!|
|
|mustbevalidname|can be anything, oops, %abort!!|
|
||||||
|
|
||||||
@param [in] debug= (log) Provide the _debug value
|
@param [in] debug= (log) Provide the _debug value
|
||||||
@param [in] viyaresult=(WEBOUT_JSON) The Viya result type to return. For
|
@param [in] mdebug= (0) Set to 1 to provide macro debugging
|
||||||
|
@param [in] viyaresult= (WEBOUT_JSON) The Viya result type to return. For
|
||||||
more info, see mv_getjobresult.sas
|
more info, see mv_getjobresult.sas
|
||||||
|
@param [in] viyacontext= (SAS Job Execution compute context) The Viya compute
|
||||||
|
context on which to run the service
|
||||||
@param [out] outlib= (0) Output libref to contain the final tables. Set to
|
@param [out] outlib= (0) Output libref to contain the final tables. Set to
|
||||||
0 if the service output is not in JSON format.
|
0 if the service output is not in JSON format.
|
||||||
@param [out] outref= (0) Output fileref to create, to contain the full _webout
|
@param [out] outref= (0) Output fileref to create, to contain the full _webout
|
||||||
@@ -6266,17 +6392,18 @@ libname &lib clear;
|
|||||||
inputfiles=0,
|
inputfiles=0,
|
||||||
inputparams=0,
|
inputparams=0,
|
||||||
debug=log,
|
debug=log,
|
||||||
|
mdebug=0,
|
||||||
outlib=0,
|
outlib=0,
|
||||||
outref=0,
|
outref=0,
|
||||||
viyaresult=WEBOUT_JSON
|
viyaresult=WEBOUT_JSON,
|
||||||
|
viyacontext=SAS Job Execution compute context
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
%local mdebug;
|
%local dbg;
|
||||||
%if &debug ne 0 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
%let mdebug=1;
|
|
||||||
%put &sysmacroname entry vars:;
|
%put &sysmacroname entry vars:;
|
||||||
%put _local_;
|
%put _local_;
|
||||||
%end;
|
%end;
|
||||||
%else %let mdebug=0;
|
%else %let dbg=*;
|
||||||
|
|
||||||
/* sanitise inputparams */
|
/* sanitise inputparams */
|
||||||
%local pcnt;
|
%local pcnt;
|
||||||
@@ -6431,6 +6558,7 @@ libname &lib clear;
|
|||||||
|
|
||||||
data &ds1;
|
data &ds1;
|
||||||
retain _program "&program";
|
retain _program "&program";
|
||||||
|
retain _contextname "&viyacontext";
|
||||||
set &ds1;
|
set &ds1;
|
||||||
putlog "&sysmacroname inputparams:";
|
putlog "&sysmacroname inputparams:";
|
||||||
putlog (_all_)(=);
|
putlog (_all_)(=);
|
||||||
@@ -12702,9 +12830,7 @@ data _null_;
|
|||||||
putlog _infile_;
|
putlog _infile_;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
|
%mend mmx_deletemetafolder;/**
|
||||||
%mend mmx_deletemetafolder;
|
|
||||||
/**
|
|
||||||
@file mmx_spkexport.sas
|
@file mmx_spkexport.sas
|
||||||
@brief Exports everything in a particular metadata folder
|
@brief Exports everything in a particular metadata folder
|
||||||
@details Will export everything in a metadata folder to a specified location.
|
@details Will export everything in a metadata folder to a specified location.
|
||||||
@@ -12912,9 +13038,13 @@ run;
|
|||||||
@param [in] path= The parent folder in which to create the file
|
@param [in] path= The parent folder in which to create the file
|
||||||
@param [in] name= The name of the file to be created
|
@param [in] name= The name of the file to be created
|
||||||
@param [in] inref= The fileref pointing to the file to be uploaded
|
@param [in] inref= The fileref pointing to the file to be uploaded
|
||||||
|
@param [in] intype= (BINARY) The type of the input data. Valid values:
|
||||||
|
@li BINARY File is copied byte for byte using the mp_binarycopy.sas macro.
|
||||||
|
@li BASE64 File will be first decoded using the mp_base64.sas macro, then
|
||||||
|
loaded byte by byte to SAS Drive.
|
||||||
@param [in] contentdisp= (inline) Content Disposition. Example values:
|
@param [in] contentdisp= (inline) Content Disposition. Example values:
|
||||||
@li inline
|
@li inline
|
||||||
@li attachment
|
@li attachment
|
||||||
|
|
||||||
@param [in] access_token_var= The global macro variable to contain the access
|
@param [in] access_token_var= The global macro variable to contain the access
|
||||||
token, if using authorization_code grant type.
|
token, if using authorization_code grant type.
|
||||||
@@ -12932,6 +13062,7 @@ run;
|
|||||||
@li mf_getuniquefileref.sas
|
@li mf_getuniquefileref.sas
|
||||||
@li mf_isblank.sas
|
@li mf_isblank.sas
|
||||||
@li mp_abort.sas
|
@li mp_abort.sas
|
||||||
|
@li mp_base64copy.sas
|
||||||
@li mp_binarycopy.sas
|
@li mp_binarycopy.sas
|
||||||
@li mv_createfolder.sas
|
@li mv_createfolder.sas
|
||||||
|
|
||||||
@@ -12940,6 +13071,7 @@ run;
|
|||||||
%macro mv_createfile(path=
|
%macro mv_createfile(path=
|
||||||
,name=
|
,name=
|
||||||
,inref=
|
,inref=
|
||||||
|
,intype=BINARY
|
||||||
,contentdisp=inline
|
,contentdisp=inline
|
||||||
,access_token_var=ACCESS_TOKEN
|
,access_token_var=ACCESS_TOKEN
|
||||||
,grant_type=sas_services
|
,grant_type=sas_services
|
||||||
@@ -12994,7 +13126,12 @@ filename &fref filesrvc
|
|||||||
cdisp="&contentdisp"
|
cdisp="&contentdisp"
|
||||||
lrecl=1048544;
|
lrecl=1048544;
|
||||||
|
|
||||||
%mp_binarycopy(inref=&inref, outref=&fref)
|
%if &intype=BINARY %then %do;
|
||||||
|
%mp_binarycopy(inref=&inref, outref=&fref)
|
||||||
|
%end;
|
||||||
|
%else %if &intype=BASE64 %then %do;
|
||||||
|
%mp_base64copy(inref=&inref, outref=&fref, action=DECODE)
|
||||||
|
%end;
|
||||||
|
|
||||||
filename &fref clear;
|
filename &fref clear;
|
||||||
|
|
||||||
@@ -15439,7 +15576,7 @@ run;
|
|||||||
|
|
||||||
@param [in] access_token_var= The global macro variable to contain the access
|
@param [in] access_token_var= The global macro variable to contain the access
|
||||||
token
|
token
|
||||||
@param [in] mdebug= set to 1 to enable DEBUG messages
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
@param [in] grant_type= valid values:
|
@param [in] grant_type= valid values:
|
||||||
@li password
|
@li password
|
||||||
@li authorization_code
|
@li authorization_code
|
||||||
@@ -15464,7 +15601,6 @@ run;
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
%macro mv_getjoblog(uri=0,outref=0
|
%macro mv_getjoblog(uri=0,outref=0
|
||||||
,contextName=SAS Job Execution compute context
|
|
||||||
,access_token_var=ACCESS_TOKEN
|
,access_token_var=ACCESS_TOKEN
|
||||||
,grant_type=sas_services
|
,grant_type=sas_services
|
||||||
,mdebug=0
|
,mdebug=0
|
||||||
@@ -15785,7 +15921,6 @@ run;
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
%macro mv_getjobresult(uri=0
|
%macro mv_getjobresult(uri=0
|
||||||
,contextName=SAS Job Execution compute context
|
|
||||||
,access_token_var=ACCESS_TOKEN
|
,access_token_var=ACCESS_TOKEN
|
||||||
,grant_type=sas_services
|
,grant_type=sas_services
|
||||||
,mdebug=0
|
,mdebug=0
|
||||||
@@ -15899,10 +16034,11 @@ proc http method='GET' out=&fname2 &oauth_bearer
|
|||||||
;
|
;
|
||||||
run;
|
run;
|
||||||
%if &mdebug=1 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
|
/* send one char at a time as the json can be very wide */
|
||||||
data _null_;
|
data _null_;
|
||||||
infile &fname2 lrecl=32767;
|
infile &fname2 recfm=n;
|
||||||
input;
|
input char $char1. ;
|
||||||
putlog _infile_;
|
putlog char $char1. @;
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
@@ -16659,6 +16795,11 @@ run;
|
|||||||
%if &mdebug=1 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
%put &sysmacroname entry vars:;
|
%put &sysmacroname entry vars:;
|
||||||
%put _local_;
|
%put _local_;
|
||||||
|
%put inds vars:;
|
||||||
|
data _null_;
|
||||||
|
set &inds;
|
||||||
|
putlog (_all_)(=);
|
||||||
|
run;
|
||||||
%end;
|
%end;
|
||||||
%else %let dbg=*;
|
%else %let dbg=*;
|
||||||
|
|
||||||
@@ -16703,6 +16844,7 @@ run;
|
|||||||
retain FLOW_ID 0;
|
retain FLOW_ID 0;
|
||||||
%end;
|
%end;
|
||||||
set &inds;
|
set &inds;
|
||||||
|
&dbg. putlog (_all_)(=);
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
@@ -16767,6 +16909,8 @@ data;run;%let jdswaitfor=&syslast;
|
|||||||
call symputx(cats('job',_n_),_program,'l');
|
call symputx(cats('job',_n_),_program,'l');
|
||||||
call symputx(cats('context',_n_),_contextName,'l');
|
call symputx(cats('context',_n_),_contextName,'l');
|
||||||
call symputx('jcnt',_n_,'l');
|
call symputx('jcnt',_n_,'l');
|
||||||
|
&dbg. if _n_= 1 then putlog "Loop &fid";
|
||||||
|
&dbg. putlog (_all_)(=);
|
||||||
run;
|
run;
|
||||||
%put exporting job variables in json format;
|
%put exporting job variables in json format;
|
||||||
%do jid=1 %to &jcnt;
|
%do jid=1 %to &jcnt;
|
||||||
@@ -16828,6 +16972,7 @@ data;run;%let jdswaitfor=&syslast;
|
|||||||
,name=&jobname
|
,name=&jobname
|
||||||
,paramstring=%superq(jparams&jid)
|
,paramstring=%superq(jparams&jid)
|
||||||
,outds=&jdsapp
|
,outds=&jdsapp
|
||||||
|
,contextname=&&context&jid
|
||||||
)
|
)
|
||||||
data &jdsapp;
|
data &jdsapp;
|
||||||
format jobparams $32767.;
|
format jobparams $32767.;
|
||||||
|
|||||||
@@ -165,6 +165,7 @@
|
|||||||
sysuserid=symget('sysuserid');
|
sysuserid=symget('sysuserid');
|
||||||
iftrue=symget('iftrue');
|
iftrue=symget('iftrue');
|
||||||
put (_all_)(/=);
|
put (_all_)(/=);
|
||||||
|
call symputx('syscc',0);
|
||||||
abort cancel nolist;
|
abort cancel nolist;
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|||||||
123
base/mp_base64copy.sas
Normal file
123
base/mp_base64copy.sas
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Convert a file to/from base64 format
|
||||||
|
@details Creates a new version of a file either encoded or decoded using
|
||||||
|
Base64. Inspired by this post by Michael Dixon:
|
||||||
|
https://support.selerity.com.au/hc/en-us/articles/223345708-Tip-SAS-and-Base64
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
filename tmp temp;
|
||||||
|
data _null_;
|
||||||
|
file tmp;
|
||||||
|
put 'base ik ally';
|
||||||
|
run;
|
||||||
|
%mp_base64copy(inref=tmp, outref=myref, action=ENCODE)
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
infile myref;
|
||||||
|
input;
|
||||||
|
put _infile_;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_base64copy(inref=myref, outref=mynewref, action=DECODE)
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
infile mynewref;
|
||||||
|
input;
|
||||||
|
put _infile_;
|
||||||
|
run;
|
||||||
|
|
||||||
|
@param [in] inref= Fileref of the input file (should exist)
|
||||||
|
@param [out] outref= Output fileref. If it does not exist, it is created.
|
||||||
|
@param [in] action= (ENCODE) The action to take. Valid values:
|
||||||
|
@li ENCODE - Convert the file to base64 format
|
||||||
|
@li DECODE - Decode the file from base64 format
|
||||||
|
|
||||||
|
@version 9.2
|
||||||
|
@author Allan Bowe, source: https://github.com/sasjs/core
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mp_abort.sas
|
||||||
|
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mp_base64copy(
|
||||||
|
inref=0,
|
||||||
|
outref=0,
|
||||||
|
action=ENCODE
|
||||||
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
|
%let inref=%upcase(&inref);
|
||||||
|
%let outref=%upcase(&outref);
|
||||||
|
%let action=%upcase(&action);
|
||||||
|
%local infound outfound;
|
||||||
|
%let infound=0;
|
||||||
|
%let outfound=0;
|
||||||
|
data _null_;
|
||||||
|
set sashelp.vextfl(where=(fileref="&inref" or fileref="&outref"));
|
||||||
|
if fileref="&inref" then call symputx('infound',1,'l');
|
||||||
|
if fileref="&outref" then call symputx('outfound',1,'l');
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_abort(iftrue= (&infound=0)
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(INREF &inref NOT FOUND!)
|
||||||
|
)
|
||||||
|
%mp_abort(iftrue= (&outref=0)
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(OUTREF NOT PROVIDED!)
|
||||||
|
)
|
||||||
|
%mp_abort(iftrue= (&action ne ENCODE and &action ne DECODE)
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(Invalid action! Should be ENCODE OR DECODE)
|
||||||
|
)
|
||||||
|
|
||||||
|
%if &outfound=0 %then %do;
|
||||||
|
filename &outref temp lrecl=2097088;
|
||||||
|
%%end;
|
||||||
|
|
||||||
|
%if &action=ENCODE %then %do;
|
||||||
|
data _null_;
|
||||||
|
length b64 $ 76 line $ 57;
|
||||||
|
retain line "";
|
||||||
|
infile &inref recfm=F lrecl= 1 end=eof;
|
||||||
|
input @1 stream $char1.;
|
||||||
|
file &outref lrecl=76;
|
||||||
|
substr(line,(_N_-(CEIL(_N_/57)-1)*57),1) = byte(rank(stream));
|
||||||
|
if mod(_N_,57)=0 or EOF then do;
|
||||||
|
if eof then b64=put(trim(line),$base64X76.);
|
||||||
|
else b64=put(line, $base64X76.);
|
||||||
|
put b64;
|
||||||
|
line="";
|
||||||
|
end;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %if &action=DECODE %then %do;
|
||||||
|
data _null_;
|
||||||
|
length filein 8 fileout 8;
|
||||||
|
filein = fopen("&inref",'I',4,'B');
|
||||||
|
fileout = fopen("&outref",'O',3,'B');
|
||||||
|
char= '20'x;
|
||||||
|
do while(fread(filein)=0);
|
||||||
|
raw="1234";
|
||||||
|
do i=1 to 4;
|
||||||
|
rc=fget(filein,char,1);
|
||||||
|
substr(raw,i,1)=char;
|
||||||
|
end;
|
||||||
|
val="123";
|
||||||
|
val=input(raw,$base64X4.);
|
||||||
|
do i=1 to 3;
|
||||||
|
length byte $1;
|
||||||
|
byte=byte(rank(substr(val,i,1)));
|
||||||
|
rc = fput(fileout, byte);
|
||||||
|
end;
|
||||||
|
rc =fwrite(fileout);
|
||||||
|
end;
|
||||||
|
rc = fclose(filein);
|
||||||
|
rc = fclose(fileout);
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
%mend mp_base64copy;
|
||||||
@@ -22,8 +22,11 @@
|
|||||||
|mustbevalidname|can be anything, oops, %abort!!|
|
|mustbevalidname|can be anything, oops, %abort!!|
|
||||||
|
|
||||||
@param [in] debug= (log) Provide the _debug value
|
@param [in] debug= (log) Provide the _debug value
|
||||||
@param [in] viyaresult=(WEBOUT_JSON) The Viya result type to return. For
|
@param [in] mdebug= (0) Set to 1 to provide macro debugging
|
||||||
|
@param [in] viyaresult= (WEBOUT_JSON) The Viya result type to return. For
|
||||||
more info, see mv_getjobresult.sas
|
more info, see mv_getjobresult.sas
|
||||||
|
@param [in] viyacontext= (SAS Job Execution compute context) The Viya compute
|
||||||
|
context on which to run the service
|
||||||
@param [out] outlib= (0) Output libref to contain the final tables. Set to
|
@param [out] outlib= (0) Output libref to contain the final tables. Set to
|
||||||
0 if the service output is not in JSON format.
|
0 if the service output is not in JSON format.
|
||||||
@param [out] outref= (0) Output fileref to create, to contain the full _webout
|
@param [out] outref= (0) Output fileref to create, to contain the full _webout
|
||||||
@@ -47,17 +50,18 @@
|
|||||||
inputfiles=0,
|
inputfiles=0,
|
||||||
inputparams=0,
|
inputparams=0,
|
||||||
debug=log,
|
debug=log,
|
||||||
|
mdebug=0,
|
||||||
outlib=0,
|
outlib=0,
|
||||||
outref=0,
|
outref=0,
|
||||||
viyaresult=WEBOUT_JSON
|
viyaresult=WEBOUT_JSON,
|
||||||
|
viyacontext=SAS Job Execution compute context
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
%local mdebug;
|
%local dbg;
|
||||||
%if &debug ne 0 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
%let mdebug=1;
|
|
||||||
%put &sysmacroname entry vars:;
|
%put &sysmacroname entry vars:;
|
||||||
%put _local_;
|
%put _local_;
|
||||||
%end;
|
%end;
|
||||||
%else %let mdebug=0;
|
%else %let dbg=*;
|
||||||
|
|
||||||
/* sanitise inputparams */
|
/* sanitise inputparams */
|
||||||
%local pcnt;
|
%local pcnt;
|
||||||
@@ -212,6 +216,7 @@
|
|||||||
|
|
||||||
data &ds1;
|
data &ds1;
|
||||||
retain _program "&program";
|
retain _program "&program";
|
||||||
|
retain _contextname "&viyacontext";
|
||||||
set &ds1;
|
set &ds1;
|
||||||
putlog "&sysmacroname inputparams:";
|
putlog "&sysmacroname inputparams:";
|
||||||
putlog (_all_)(=);
|
putlog (_all_)(=);
|
||||||
|
|||||||
@@ -33,6 +33,6 @@
|
|||||||
"postinstall": "[ -d .git ] && git config core.hooksPath ./.git-hooks || true"
|
"postinstall": "[ -d .git ] && git config core.hooksPath ./.git-hooks || true"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sasjs/cli": "^2.27.0"
|
"@sasjs/cli": "2.27.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,9 +17,13 @@
|
|||||||
@param [in] path= The parent folder in which to create the file
|
@param [in] path= The parent folder in which to create the file
|
||||||
@param [in] name= The name of the file to be created
|
@param [in] name= The name of the file to be created
|
||||||
@param [in] inref= The fileref pointing to the file to be uploaded
|
@param [in] inref= The fileref pointing to the file to be uploaded
|
||||||
|
@param [in] intype= (BINARY) The type of the input data. Valid values:
|
||||||
|
@li BINARY File is copied byte for byte using the mp_binarycopy.sas macro.
|
||||||
|
@li BASE64 File will be first decoded using the mp_base64.sas macro, then
|
||||||
|
loaded byte by byte to SAS Drive.
|
||||||
@param [in] contentdisp= (inline) Content Disposition. Example values:
|
@param [in] contentdisp= (inline) Content Disposition. Example values:
|
||||||
@li inline
|
@li inline
|
||||||
@li attachment
|
@li attachment
|
||||||
|
|
||||||
@param [in] access_token_var= The global macro variable to contain the access
|
@param [in] access_token_var= The global macro variable to contain the access
|
||||||
token, if using authorization_code grant type.
|
token, if using authorization_code grant type.
|
||||||
@@ -37,6 +41,7 @@
|
|||||||
@li mf_getuniquefileref.sas
|
@li mf_getuniquefileref.sas
|
||||||
@li mf_isblank.sas
|
@li mf_isblank.sas
|
||||||
@li mp_abort.sas
|
@li mp_abort.sas
|
||||||
|
@li mp_base64copy.sas
|
||||||
@li mp_binarycopy.sas
|
@li mp_binarycopy.sas
|
||||||
@li mv_createfolder.sas
|
@li mv_createfolder.sas
|
||||||
|
|
||||||
@@ -45,6 +50,7 @@
|
|||||||
%macro mv_createfile(path=
|
%macro mv_createfile(path=
|
||||||
,name=
|
,name=
|
||||||
,inref=
|
,inref=
|
||||||
|
,intype=BINARY
|
||||||
,contentdisp=inline
|
,contentdisp=inline
|
||||||
,access_token_var=ACCESS_TOKEN
|
,access_token_var=ACCESS_TOKEN
|
||||||
,grant_type=sas_services
|
,grant_type=sas_services
|
||||||
@@ -99,7 +105,12 @@ filename &fref filesrvc
|
|||||||
cdisp="&contentdisp"
|
cdisp="&contentdisp"
|
||||||
lrecl=1048544;
|
lrecl=1048544;
|
||||||
|
|
||||||
%mp_binarycopy(inref=&inref, outref=&fref)
|
%if &intype=BINARY %then %do;
|
||||||
|
%mp_binarycopy(inref=&inref, outref=&fref)
|
||||||
|
%end;
|
||||||
|
%else %if &intype=BASE64 %then %do;
|
||||||
|
%mp_base64copy(inref=&inref, outref=&fref, action=DECODE)
|
||||||
|
%end;
|
||||||
|
|
||||||
filename &fref clear;
|
filename &fref clear;
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
|
|
||||||
@param [in] access_token_var= The global macro variable to contain the access
|
@param [in] access_token_var= The global macro variable to contain the access
|
||||||
token
|
token
|
||||||
@param [in] mdebug= set to 1 to enable DEBUG messages
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
@param [in] grant_type= valid values:
|
@param [in] grant_type= valid values:
|
||||||
@li password
|
@li password
|
||||||
@li authorization_code
|
@li authorization_code
|
||||||
@@ -91,7 +91,6 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
%macro mv_getjoblog(uri=0,outref=0
|
%macro mv_getjoblog(uri=0,outref=0
|
||||||
,contextName=SAS Job Execution compute context
|
|
||||||
,access_token_var=ACCESS_TOKEN
|
,access_token_var=ACCESS_TOKEN
|
||||||
,grant_type=sas_services
|
,grant_type=sas_services
|
||||||
,mdebug=0
|
,mdebug=0
|
||||||
|
|||||||
@@ -90,7 +90,6 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
%macro mv_getjobresult(uri=0
|
%macro mv_getjobresult(uri=0
|
||||||
,contextName=SAS Job Execution compute context
|
|
||||||
,access_token_var=ACCESS_TOKEN
|
,access_token_var=ACCESS_TOKEN
|
||||||
,grant_type=sas_services
|
,grant_type=sas_services
|
||||||
,mdebug=0
|
,mdebug=0
|
||||||
@@ -204,10 +203,11 @@ proc http method='GET' out=&fname2 &oauth_bearer
|
|||||||
;
|
;
|
||||||
run;
|
run;
|
||||||
%if &mdebug=1 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
|
/* send one char at a time as the json can be very wide */
|
||||||
data _null_;
|
data _null_;
|
||||||
infile &fname2 lrecl=32767;
|
infile &fname2 recfm=n;
|
||||||
input;
|
input char $char1. ;
|
||||||
putlog _infile_;
|
putlog char $char1. @;
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
|
|||||||
@@ -140,6 +140,11 @@
|
|||||||
%if &mdebug=1 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
%put &sysmacroname entry vars:;
|
%put &sysmacroname entry vars:;
|
||||||
%put _local_;
|
%put _local_;
|
||||||
|
%put inds vars:;
|
||||||
|
data _null_;
|
||||||
|
set &inds;
|
||||||
|
putlog (_all_)(=);
|
||||||
|
run;
|
||||||
%end;
|
%end;
|
||||||
%else %let dbg=*;
|
%else %let dbg=*;
|
||||||
|
|
||||||
@@ -184,6 +189,7 @@
|
|||||||
retain FLOW_ID 0;
|
retain FLOW_ID 0;
|
||||||
%end;
|
%end;
|
||||||
set &inds;
|
set &inds;
|
||||||
|
&dbg. putlog (_all_)(=);
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
@@ -248,6 +254,8 @@ data;run;%let jdswaitfor=&syslast;
|
|||||||
call symputx(cats('job',_n_),_program,'l');
|
call symputx(cats('job',_n_),_program,'l');
|
||||||
call symputx(cats('context',_n_),_contextName,'l');
|
call symputx(cats('context',_n_),_contextName,'l');
|
||||||
call symputx('jcnt',_n_,'l');
|
call symputx('jcnt',_n_,'l');
|
||||||
|
&dbg. if _n_= 1 then putlog "Loop &fid";
|
||||||
|
&dbg. putlog (_all_)(=);
|
||||||
run;
|
run;
|
||||||
%put exporting job variables in json format;
|
%put exporting job variables in json format;
|
||||||
%do jid=1 %to &jcnt;
|
%do jid=1 %to &jcnt;
|
||||||
@@ -309,6 +317,7 @@ data;run;%let jdswaitfor=&syslast;
|
|||||||
,name=&jobname
|
,name=&jobname
|
||||||
,paramstring=%superq(jparams&jid)
|
,paramstring=%superq(jparams&jid)
|
||||||
,outds=&jdsapp
|
,outds=&jdsapp
|
||||||
|
,contextname=&&context&jid
|
||||||
)
|
)
|
||||||
data &jdsapp;
|
data &jdsapp;
|
||||||
format jobparams $32767.;
|
format jobparams $32767.;
|
||||||
|
|||||||
Reference in New Issue
Block a user