mirror of
https://github.com/sasjs/core.git
synced 2026-01-09 10:20:06 +00:00
Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cdf339d077 | ||
|
|
31702df19b | ||
|
|
cf0d1c0473 | ||
|
|
1f369f9848 | ||
|
|
2372ff5f4f | ||
|
|
6d0e34ba1d | ||
|
|
7a69698178 | ||
|
|
532bf84e06 | ||
|
|
e1afbc02c4 | ||
|
|
756f00d88d | ||
|
|
b72e404d52 | ||
|
|
e31cdeef42 | ||
|
|
8a4e32cc27 | ||
|
|
f285505b79 | ||
|
|
67f5c50300 | ||
|
|
ce39e4f779 | ||
|
|
9c80f5664c | ||
|
|
83466c001b | ||
|
|
ad315be503 | ||
|
|
c41ae2dcc8 | ||
| d9f8e92fac | |||
|
|
d42ede15db | ||
|
|
08ea9f7c00 | ||
|
|
c327e1fc0d | ||
|
|
02fddcf9a1 | ||
|
|
4752bfbb05 | ||
|
|
767ddd7add |
17
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
17
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
## Issue
|
||||||
|
|
||||||
|
Link any related issue(s) in this section.
|
||||||
|
|
||||||
|
## Intent
|
||||||
|
|
||||||
|
What this PR intends to achieve.
|
||||||
|
|
||||||
|
## Implementation
|
||||||
|
|
||||||
|
What code changes have been made to achieve the intent.
|
||||||
|
|
||||||
|
## Checks
|
||||||
|
|
||||||
|
- [ ] Code is formatted correctly (`sasjs lint`).
|
||||||
|
- [ ] Any new functionality has been unit tested.
|
||||||
|
- [ ] All unit tests are passing (`sasjs test`).
|
||||||
487
all.sas
487
all.sas
@@ -2191,8 +2191,10 @@ Usage:
|
|||||||
|
|
||||||
The method used varies according to the context. Important points:
|
The method used varies according to the context. Important points:
|
||||||
|
|
||||||
@li should not use endsas or abort cancel in 9.4m3 environments as this can
|
@li should not use endsas or abort cancel in 9.4m3 WIN environments as this
|
||||||
cause hung multibridge sessions and result in a frozen STP server
|
can cause hung multibridge sessions and result in a frozen STP server
|
||||||
|
@li The use of endsas in 9.4m6+ windows environments for POST requests to the
|
||||||
|
STP server can result in an empty response body
|
||||||
@li should not use endsas in viya 3.5 as this destroys the session and cannot
|
@li should not use endsas in viya 3.5 as this destroys the session and cannot
|
||||||
fetch results (although both mv_getjoblog.sas and the @sasjs/adapter will
|
fetch results (although both mv_getjoblog.sas and the @sasjs/adapter will
|
||||||
recognise this and fetch the log of the parent session instead)
|
recognise this and fetch the log of the parent session instead)
|
||||||
@@ -2204,8 +2206,8 @@ Usage:
|
|||||||
a macro. For that, we recommend you use mp_include.sas to perform the
|
a macro. For that, we recommend you use mp_include.sas to perform the
|
||||||
include, and then call \%mp_abort(mode=INCLUDE) from the source program (ie,
|
include, and then call \%mp_abort(mode=INCLUDE) from the source program (ie,
|
||||||
OUTSIDE of the top-parent macro).
|
OUTSIDE of the top-parent macro).
|
||||||
The soft abort has also been found to be ineffective in 9.4m6 windows
|
The soft abort has become ineffective in 9.4m6 WINDOWS environments. We are
|
||||||
environments and above, so in these cases, endsas is used.
|
currently investigating approaches to deal with this.
|
||||||
|
|
||||||
|
|
||||||
@param mac= (mp_abort.sas) To contain the name of the calling macro. Do not
|
@param mac= (mp_abort.sas) To contain the name of the calling macro. Do not
|
||||||
@@ -2246,7 +2248,7 @@ Usage:
|
|||||||
, mode=REGULAR
|
, mode=REGULAR
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
%global sysprocessmode sysprocessname sasjs_stpsrv_header_loc;
|
%global sysprocessmode sysprocessname sasjs_stpsrv_header_loc sasjsprocessmode;
|
||||||
%local fref fid i;
|
%local fref fid i;
|
||||||
|
|
||||||
%if not(%eval(%unquote(&iftrue))) %then %return;
|
%if not(%eval(%unquote(&iftrue))) %then %return;
|
||||||
@@ -2430,6 +2432,7 @@ Usage:
|
|||||||
call symputx("syscc",0,"g");
|
call symputx("syscc",0,"g");
|
||||||
run;
|
run;
|
||||||
%if &sysscp=WIN
|
%if &sysscp=WIN
|
||||||
|
and 1=0 /* deprecating this logic until we figure out a consistent abort */
|
||||||
and "%substr(%str(&sysvlong ),1,8)"="9.04.01M"
|
and "%substr(%str(&sysvlong ),1,8)"="9.04.01M"
|
||||||
and "%substr(%str(&sysvlong ),9,1)">"5" %then %do;
|
and "%substr(%str(&sysvlong ),9,1)">"5" %then %do;
|
||||||
/* skip approach (below) does not work in windows m6+ envs */
|
/* skip approach (below) does not work in windows m6+ envs */
|
||||||
@@ -3470,8 +3473,8 @@ run;
|
|||||||
@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
|
||||||
os-independent method to copy files. In case of naming collision, the
|
os-independent method to copy files. In case of naming collision, the
|
||||||
default filerefs can be modified.
|
default filerefs can be modified.
|
||||||
Based on:
|
Note that if you have a new enough version of SAS, and you don't need features
|
||||||
https://stackoverflow.com/questions/13046116/using-sas-to-copy-a-text-file
|
such as APPEND, you may be better of using the fcopy() function instead.
|
||||||
|
|
||||||
%mp_binarycopy(inloc="/home/me/blah.txt", outref=_webout)
|
%mp_binarycopy(inloc="/home/me/blah.txt", outref=_webout)
|
||||||
|
|
||||||
@@ -3511,14 +3514,9 @@ run;
|
|||||||
,outref=____out /* override default to use own filerefs */
|
,outref=____out /* override default to use own filerefs */
|
||||||
,mode=CREATE
|
,mode=CREATE
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
%local mod outmode;
|
%local mod;
|
||||||
%if &mode=APPEND %then %do;
|
%if &mode=APPEND %then %let mod=mod;
|
||||||
%let mod=mod;
|
|
||||||
%let outmode='a';
|
|
||||||
%end;
|
|
||||||
%else %do;
|
|
||||||
%let outmode='o';
|
|
||||||
%end;
|
|
||||||
/* these IN and OUT filerefs can point to anything */
|
/* these IN and OUT filerefs can point to anything */
|
||||||
%if &inref = ____in %then %do;
|
%if &inref = ____in %then %do;
|
||||||
filename &inref &inloc lrecl=1048576 ;
|
filename &inref &inloc lrecl=1048576 ;
|
||||||
@@ -3529,25 +3527,21 @@ run;
|
|||||||
|
|
||||||
/* copy the file byte-for-byte */
|
/* copy the file byte-for-byte */
|
||||||
data _null_;
|
data _null_;
|
||||||
length filein 8 fileid 8;
|
infile &inref lrecl=1 recfm=n;
|
||||||
filein = fopen("&inref",'I',1,'B');
|
file &outref &mod recfm=n;
|
||||||
fileid = fopen("&outref",&outmode,1,'B');
|
input sourcechar $char1. @@;
|
||||||
rec = '20'x;
|
format sourcechar hex2.;
|
||||||
do while(fread(filein)=0);
|
put sourcechar char1. @@;
|
||||||
rc = fget(filein,rec,1);
|
|
||||||
rc = fput(fileid, rec);
|
|
||||||
rc =fwrite(fileid);
|
|
||||||
end;
|
|
||||||
rc = fclose(filein);
|
|
||||||
rc = fclose(fileid);
|
|
||||||
run;
|
run;
|
||||||
|
|
||||||
%if &inref = ____in %then %do;
|
%if &inref = ____in %then %do;
|
||||||
filename &inref clear;
|
filename &inref clear;
|
||||||
%end;
|
%end;
|
||||||
%if &outref=____out %then %do;
|
%if &outref=____out %then %do;
|
||||||
filename &outref clear;
|
filename &outref clear;
|
||||||
%end;
|
%end;
|
||||||
%mend mp_binarycopy;/**
|
%mend mp_binarycopy;
|
||||||
|
/**
|
||||||
@file
|
@file
|
||||||
@brief Splits a file of ANY SIZE by reference to a search string.
|
@brief Splits a file of ANY SIZE by reference to a search string.
|
||||||
@details Provide a fileref and a search string to chop off part of a file.
|
@details Provide a fileref and a search string to chop off part of a file.
|
||||||
@@ -4803,7 +4797,7 @@ drop table &out_ds;
|
|||||||
@cond
|
@cond
|
||||||
**/
|
**/
|
||||||
|
|
||||||
%macro mp_ds2cards(base_ds=, tgt_ds=
|
%macro mp_ds2cards(base_ds, tgt_ds=
|
||||||
,cards_file="%sysfunc(pathname(work))/cardgen.sas"
|
,cards_file="%sysfunc(pathname(work))/cardgen.sas"
|
||||||
,maxobs=max
|
,maxobs=max
|
||||||
,random_sample=NO
|
,random_sample=NO
|
||||||
@@ -5006,6 +5000,7 @@ data _null_;
|
|||||||
;
|
;
|
||||||
%end;
|
%end;
|
||||||
put ";";
|
put ";";
|
||||||
|
put 'missing a b c d e f g h i j k l m n o p q r s t u v w x y z _;';
|
||||||
put "datalines4;";
|
put "datalines4;";
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@@ -8583,7 +8578,12 @@ options
|
|||||||
/**
|
/**
|
||||||
@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 This macro can be used to OPEN a JSON stream and send one or more
|
||||||
|
tables as arrays of rows, where each row can be an object or a nested array.
|
||||||
|
|
||||||
|
There are two engines available - DATASTEP or PROCJSON.
|
||||||
|
|
||||||
|
PROC JSON is fast but will produce errs like the ones below if
|
||||||
special chars are encountered.
|
special chars are encountered.
|
||||||
|
|
||||||
> (ERR)OR: Some code points did not transcode.
|
> (ERR)OR: Some code points did not transcode.
|
||||||
@@ -8594,6 +8594,10 @@ options
|
|||||||
|
|
||||||
If this happens, try running with ENGINE=DATASTEP.
|
If this happens, try running with ENGINE=DATASTEP.
|
||||||
|
|
||||||
|
The DATASTEP engine is used to handle special SAS missing numerics, and
|
||||||
|
can also convert entire datasets to formatted values. Output JSON is always
|
||||||
|
in UTF-8.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
filename tmp temp;
|
filename tmp temp;
|
||||||
@@ -8657,9 +8661,23 @@ options
|
|||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
%else %if (&action=ARR or &action=OBJ) %then %do;
|
%else %if (&action=ARR or &action=OBJ) %then %do;
|
||||||
|
/* force variable names to always be uppercase in the JSON */
|
||||||
options validvarname=upcase;
|
options validvarname=upcase;
|
||||||
data _null_; file &jref encoding='utf-8' mod;
|
/* To avoid issues with _webout on EBI - such as encoding diffs and truncation
|
||||||
|
(https://support.sas.com/kb/49/325.html) we use temporary files */
|
||||||
|
filename _sjs1 temp lrecl=200 ;
|
||||||
|
data _null_; file _sjs1 encoding='utf-8';
|
||||||
put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":";
|
put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":";
|
||||||
|
run;
|
||||||
|
/* now write to _webout 1 char at a time */
|
||||||
|
data _null_;
|
||||||
|
infile _sjs1 lrecl=1 recfm=n;
|
||||||
|
file &jref mod lrecl=1 recfm=n;
|
||||||
|
input sourcechar $char1. @@;
|
||||||
|
format sourcechar hex2.;
|
||||||
|
put sourcechar char1. @@;
|
||||||
|
run;
|
||||||
|
filename _sjs1 clear;
|
||||||
|
|
||||||
/* grab col defs */
|
/* grab col defs */
|
||||||
proc contents noprint data=&ds
|
proc contents noprint data=&ds
|
||||||
@@ -8716,10 +8734,20 @@ options
|
|||||||
data &tempds;set &ds;
|
data &tempds;set &ds;
|
||||||
%if &fmt=N %then format _numeric_ best32.;;
|
%if &fmt=N %then format _numeric_ best32.;;
|
||||||
/* PRETTY is necessary to avoid line truncation in large files */
|
/* PRETTY is necessary to avoid line truncation in large files */
|
||||||
proc json out=&jref pretty
|
filename _sjs2 temp lrecl=131068 encoding='utf-8';
|
||||||
|
proc json out=_sjs2 pretty
|
||||||
%if &action=ARR %then nokeys ;
|
%if &action=ARR %then nokeys ;
|
||||||
;export &tempds / nosastags fmtnumeric;
|
;export &tempds / nosastags fmtnumeric;
|
||||||
run;
|
run;
|
||||||
|
/* send back to webout */
|
||||||
|
data _null_;
|
||||||
|
infile _sjs2 lrecl=1 recfm=n;
|
||||||
|
file &jref mod lrecl=1 recfm=n;
|
||||||
|
input sourcechar $char1. @@;
|
||||||
|
format sourcechar hex2.;
|
||||||
|
put sourcechar char1. @@;
|
||||||
|
run;
|
||||||
|
filename _sjs2 clear;
|
||||||
%end;
|
%end;
|
||||||
%else %if &engine=DATASTEP %then %do;
|
%else %if &engine=DATASTEP %then %do;
|
||||||
%datastep:
|
%datastep:
|
||||||
@@ -8802,10 +8830,9 @@ options
|
|||||||
%end;
|
%end;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
/* write to temp loc to avoid _webout truncation
|
filename _sjs3 temp lrecl=131068 ;
|
||||||
- https://support.sas.com/kb/49/325.html */
|
data _null_;
|
||||||
filename _sjs temp lrecl=131068 encoding='utf-8';
|
file _sjs3 encoding='utf-8';
|
||||||
data _null_; file _sjs lrecl=131068 encoding='utf-8' mod ;
|
|
||||||
if _n_=1 then put "[";
|
if _n_=1 then put "[";
|
||||||
set &tempds;
|
set &tempds;
|
||||||
if _n_>1 then put "," @; put
|
if _n_>1 then put "," @; put
|
||||||
@@ -8816,36 +8843,34 @@ options
|
|||||||
"&&name&i"n /* name literal for reserved variable names */
|
"&&name&i"n /* name literal for reserved variable names */
|
||||||
%end;
|
%end;
|
||||||
%if &action=ARR %then "]" ; %else "}" ; ;
|
%if &action=ARR %then "]" ; %else "}" ; ;
|
||||||
/* now write the long strings to _webout 1 byte at a time */
|
|
||||||
data _null_;
|
|
||||||
length filein 8 fileid 8;
|
|
||||||
filein=fopen("_sjs",'I',1,'B');
|
|
||||||
fileid=fopen("&jref",'A',1,'B');
|
|
||||||
rec='20'x;
|
|
||||||
do while(fread(filein)=0);
|
|
||||||
rc=fget(filein,rec,1);
|
|
||||||
rc=fput(fileid, rec);
|
|
||||||
rc=fwrite(fileid);
|
|
||||||
end;
|
|
||||||
/* close out the table */
|
/* close out the table */
|
||||||
rc=fput(fileid, "]");
|
data _null_;
|
||||||
rc=fwrite(fileid);
|
file _sjs3 mod encoding='utf-8';
|
||||||
rc=fclose(filein);
|
put ']';
|
||||||
rc=fclose(fileid);
|
|
||||||
run;
|
run;
|
||||||
filename _sjs clear;
|
data _null_;
|
||||||
|
infile _sjs3 lrecl=1 recfm=n;
|
||||||
|
file &jref mod lrecl=1 recfm=n;
|
||||||
|
input sourcechar $char1. @@;
|
||||||
|
format sourcechar hex2.;
|
||||||
|
put sourcechar char1. @@;
|
||||||
|
run;
|
||||||
|
filename _sjs3 clear;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
proc sql;
|
proc sql;
|
||||||
drop table &colinfo, &tempds;
|
drop table &colinfo, &tempds;
|
||||||
|
|
||||||
%if &showmeta=YES %then %do;
|
%if &showmeta=YES %then %do;
|
||||||
data _null_; file &jref encoding='utf-8' mod;
|
filename _sjs4 temp lrecl=131068 encoding='utf-8';
|
||||||
|
data _null_;
|
||||||
|
file _sjs4;
|
||||||
put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{";
|
put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{";
|
||||||
do i=1 to &numcols;
|
do i=1 to &numcols;
|
||||||
name=quote(trim(symget(cats('name',i))));
|
name=quote(trim(symget(cats('name',i))));
|
||||||
format=quote(trim(symget(cats('fmt',i))));
|
format=quote(trim(symget(cats('fmt',i))));
|
||||||
label=quote(trim(symget(cats('label',i))));
|
label=quote(prxchange('s/\\/\\\\/',-1,trim(symget(cats('label',i)))));
|
||||||
length=quote(trim(symget(cats('length',i))));
|
length=quote(trim(symget(cats('length',i))));
|
||||||
type=quote(trim(symget(cats('typelong',i))));
|
type=quote(trim(symget(cats('typelong',i))));
|
||||||
if i>1 then put "," @@;
|
if i>1 then put "," @@;
|
||||||
@@ -8854,6 +8879,15 @@ options
|
|||||||
end;
|
end;
|
||||||
put '}}';
|
put '}}';
|
||||||
run;
|
run;
|
||||||
|
/* send back to webout */
|
||||||
|
data _null_;
|
||||||
|
infile _sjs4 lrecl=1 recfm=n;
|
||||||
|
file &jref mod lrecl=1 recfm=n;
|
||||||
|
input sourcechar $char1. @@;
|
||||||
|
format sourcechar hex2.;
|
||||||
|
put sourcechar char1. @@;
|
||||||
|
run;
|
||||||
|
filename _sjs4 clear;
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
@@ -14065,7 +14099,7 @@ run;
|
|||||||
%mm_createfolder(path=/some/meta/folder)
|
%mm_createfolder(path=/some/meta/folder)
|
||||||
|
|
||||||
@param [in] path= Name of the folder to create.
|
@param [in] path= Name of the folder to create.
|
||||||
@param [in] mdebug= set DBG to 1 to disable DEBUG messages
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
|
|
||||||
|
|
||||||
@version 9.4
|
@version 9.4
|
||||||
@@ -14931,7 +14965,8 @@ run;
|
|||||||
@file mm_createwebservice.sas
|
@file mm_createwebservice.sas
|
||||||
@brief Create a Web Ready Stored Process
|
@brief Create a Web Ready Stored Process
|
||||||
@details This macro creates a Type 2 Stored Process with the mm_webout macro
|
@details This macro creates a Type 2 Stored Process with the mm_webout macro
|
||||||
included as pre-code.
|
(and dependencies) included as pre-code.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
%* compile macros ;
|
%* compile macros ;
|
||||||
@@ -15037,9 +15072,23 @@ data _null_;
|
|||||||
put ' run; ';
|
put ' run; ';
|
||||||
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 ' /* force variable names to always be uppercase in the JSON */ ';
|
||||||
put ' options validvarname=upcase; ';
|
put ' options validvarname=upcase; ';
|
||||||
put ' data _null_; file &jref encoding=''utf-8'' mod; ';
|
put ' /* To avoid issues with _webout on EBI - such as encoding diffs and truncation ';
|
||||||
|
put ' (https://support.sas.com/kb/49/325.html) we use temporary files */ ';
|
||||||
|
put ' filename _sjs1 temp lrecl=200 ; ';
|
||||||
|
put ' data _null_; file _sjs1 encoding=''utf-8''; ';
|
||||||
put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
|
put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' /* now write to _webout 1 char at a time */ ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs1 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs1 clear; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' /* grab col defs */ ';
|
put ' /* grab col defs */ ';
|
||||||
put ' proc contents noprint data=&ds ';
|
put ' proc contents noprint data=&ds ';
|
||||||
@@ -15096,10 +15145,20 @@ data _null_;
|
|||||||
put ' data &tempds;set &ds; ';
|
put ' data &tempds;set &ds; ';
|
||||||
put ' %if &fmt=N %then format _numeric_ best32.;; ';
|
put ' %if &fmt=N %then format _numeric_ best32.;; ';
|
||||||
put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
|
put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
|
||||||
put ' proc json out=&jref pretty ';
|
put ' filename _sjs2 temp lrecl=131068 encoding=''utf-8''; ';
|
||||||
|
put ' proc json out=_sjs2 pretty ';
|
||||||
put ' %if &action=ARR %then nokeys ; ';
|
put ' %if &action=ARR %then nokeys ; ';
|
||||||
put ' ;export &tempds / nosastags fmtnumeric; ';
|
put ' ;export &tempds / nosastags fmtnumeric; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
|
put ' /* send back to webout */ ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs2 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs2 clear; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' %else %if &engine=DATASTEP %then %do; ';
|
put ' %else %if &engine=DATASTEP %then %do; ';
|
||||||
put ' %datastep: ';
|
put ' %datastep: ';
|
||||||
@@ -15182,10 +15241,9 @@ data _null_;
|
|||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' /* write to temp loc to avoid _webout truncation ';
|
put ' filename _sjs3 temp lrecl=131068 ; ';
|
||||||
put ' - https://support.sas.com/kb/49/325.html */ ';
|
put ' data _null_; ';
|
||||||
put ' filename _sjs temp lrecl=131068 encoding=''utf-8''; ';
|
put ' file _sjs3 encoding=''utf-8''; ';
|
||||||
put ' data _null_; file _sjs lrecl=131068 encoding=''utf-8'' mod ; ';
|
|
||||||
put ' if _n_=1 then put "["; ';
|
put ' if _n_=1 then put "["; ';
|
||||||
put ' set &tempds; ';
|
put ' set &tempds; ';
|
||||||
put ' if _n_>1 then put "," @; put ';
|
put ' if _n_>1 then put "," @; put ';
|
||||||
@@ -15196,36 +15254,34 @@ data _null_;
|
|||||||
put ' "&&name&i"n /* name literal for reserved variable names */ ';
|
put ' "&&name&i"n /* name literal for reserved variable names */ ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
||||||
put ' /* now write the long strings to _webout 1 byte at a time */ ';
|
put ' ';
|
||||||
put ' data _null_; ';
|
|
||||||
put ' length filein 8 fileid 8; ';
|
|
||||||
put ' filein=fopen("_sjs",''I'',1,''B''); ';
|
|
||||||
put ' fileid=fopen("&jref",''A'',1,''B''); ';
|
|
||||||
put ' rec=''20''x; ';
|
|
||||||
put ' do while(fread(filein)=0); ';
|
|
||||||
put ' rc=fget(filein,rec,1); ';
|
|
||||||
put ' rc=fput(fileid, rec); ';
|
|
||||||
put ' rc=fwrite(fileid); ';
|
|
||||||
put ' end; ';
|
|
||||||
put ' /* close out the table */ ';
|
put ' /* close out the table */ ';
|
||||||
put ' rc=fput(fileid, "]"); ';
|
put ' data _null_; ';
|
||||||
put ' rc=fwrite(fileid); ';
|
put ' file _sjs3 mod encoding=''utf-8''; ';
|
||||||
put ' rc=fclose(filein); ';
|
put ' put '']''; ';
|
||||||
put ' rc=fclose(fileid); ';
|
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
put ' filename _sjs clear; ';
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs3 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs3 clear; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' proc sql; ';
|
put ' proc sql; ';
|
||||||
put ' drop table &colinfo, &tempds; ';
|
put ' drop table &colinfo, &tempds; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' %if &showmeta=YES %then %do; ';
|
put ' %if &showmeta=YES %then %do; ';
|
||||||
put ' data _null_; file &jref encoding=''utf-8'' mod; ';
|
put ' filename _sjs4 temp lrecl=131068 encoding=''utf-8''; ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' file _sjs4; ';
|
||||||
put ' put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{"; ';
|
put ' put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{"; ';
|
||||||
put ' do i=1 to &numcols; ';
|
put ' do i=1 to &numcols; ';
|
||||||
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
||||||
put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
|
put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
|
||||||
put ' label=quote(trim(symget(cats(''label'',i)))); ';
|
put ' label=quote(prxchange(''s/\\/\\\\/'',-1,trim(symget(cats(''label'',i))))); ';
|
||||||
put ' length=quote(trim(symget(cats(''length'',i)))); ';
|
put ' length=quote(trim(symget(cats(''length'',i)))); ';
|
||||||
put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
|
put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
|
||||||
put ' if i>1 then put "," @@; ';
|
put ' if i>1 then put "," @@; ';
|
||||||
@@ -15234,6 +15290,15 @@ data _null_;
|
|||||||
put ' end; ';
|
put ' end; ';
|
||||||
put ' put ''}}''; ';
|
put ' put ''}}''; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
|
put ' /* send back to webout */ ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs4 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs4 clear; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put '%end; ';
|
put '%end; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
@@ -15335,6 +15400,8 @@ data _null_;
|
|||||||
put ' ) ';
|
put ' ) ';
|
||||||
put '%end; ';
|
put '%end; ';
|
||||||
put '%else %if &action=CLOSE %then %do; ';
|
put '%else %if &action=CLOSE %then %do; ';
|
||||||
|
put ' /* To avoid issues with _webout on EBI we use a temporary file */ ';
|
||||||
|
put ' filename _sjsref temp lrecl=131068; ';
|
||||||
put ' %if %str(&_debug) ge 131 %then %do; ';
|
put ' %if %str(&_debug) ge 131 %then %do; ';
|
||||||
put ' /* if debug mode, send back first 10 records of each work table also */ ';
|
put ' /* if debug mode, send back first 10 records of each work table also */ ';
|
||||||
put ' options obs=10; ';
|
put ' options obs=10; ';
|
||||||
@@ -15348,11 +15415,11 @@ data _null_;
|
|||||||
put ' i+1; ';
|
put ' i+1; ';
|
||||||
put ' call symputx(cats(''wt'',i),name,''l''); ';
|
put ' call symputx(cats(''wt'',i),name,''l''); ';
|
||||||
put ' call symputx(''wtcnt'',i,''l''); ';
|
put ' call symputx(''wtcnt'',i,''l''); ';
|
||||||
put ' data _null_; file &fref mod encoding=''utf-8''; ';
|
put ' data _null_; file _sjsref 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 ' data _null_; file &fref mod encoding=''utf-8''; ';
|
put ' data _null_; file _sjsref 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''); ';
|
||||||
@@ -15361,16 +15428,16 @@ data _null_;
|
|||||||
put ' put " ""&wt"" : {"; ';
|
put ' put " ""&wt"" : {"; ';
|
||||||
put ' put ''"nlobs":'' nlobs; ';
|
put ' put ''"nlobs":'' nlobs; ';
|
||||||
put ' put '',"nvars":'' nvars; ';
|
put ' put '',"nvars":'' nvars; ';
|
||||||
put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=YES) ';
|
put ' %mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=YES) ';
|
||||||
put ' data _null_; file &fref mod encoding=''utf-8''; ';
|
put ' data _null_; file _sjsref mod encoding=''utf-8''; ';
|
||||||
put ' put "}"; ';
|
put ' put "}"; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' data _null_; file &fref mod encoding=''utf-8''; ';
|
put ' data _null_; file _sjsref mod encoding=''utf-8''; ';
|
||||||
put ' put "}"; ';
|
put ' put "}"; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' /* close off json */ ';
|
put ' /* close off json */ ';
|
||||||
put ' data _null_;file &fref mod encoding=''utf-8''; ';
|
put ' data _null_;file _sjsref mod encoding=''utf-8''; ';
|
||||||
put ' _PROGRAM=quote(trim(resolve(symget(''_PROGRAM'')))); ';
|
put ' _PROGRAM=quote(trim(resolve(symget(''_PROGRAM'')))); ';
|
||||||
put ' put ",""SYSUSERID"" : ""&sysuserid"" "; ';
|
put ' put ",""SYSUSERID"" : ""&sysuserid"" "; ';
|
||||||
put ' put ",""MF_GETUSER"" : ""%mf_getuser()"" "; ';
|
put ' put ",""MF_GETUSER"" : ""%mf_getuser()"" "; ';
|
||||||
@@ -15381,6 +15448,7 @@ data _null_;
|
|||||||
put ' put '',"_METAPERSON": '' _METAPERSON; ';
|
put ' put '',"_METAPERSON": '' _METAPERSON; ';
|
||||||
put ' put '',"_PROGRAM" : '' _PROGRAM ; ';
|
put ' put '',"_PROGRAM" : '' _PROGRAM ; ';
|
||||||
put ' put ",""SYSCC"" : ""&syscc"" "; ';
|
put ' put ",""SYSCC"" : ""&syscc"" "; ';
|
||||||
|
put ' put ",""SYSENCODING"" : ""&sysencoding"" "; ';
|
||||||
put ' syserrortext=quote(cats(symget(''SYSERRORTEXT''))); ';
|
put ' syserrortext=quote(cats(symget(''SYSERRORTEXT''))); ';
|
||||||
put ' put '',"SYSERRORTEXT" : '' syserrortext; ';
|
put ' put '',"SYSERRORTEXT" : '' syserrortext; ';
|
||||||
put ' put ",""SYSHOSTNAME"" : ""&syshostname"" "; ';
|
put ' put ",""SYSHOSTNAME"" : ""&syshostname"" "; ';
|
||||||
@@ -15401,6 +15469,16 @@ data _null_;
|
|||||||
put ' put ''>>weboutEND<<''; ';
|
put ' put ''>>weboutEND<<''; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
|
put ' /* now write to _webout 1 char at a time */ ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjsref lrecl=1 recfm=n; ';
|
||||||
|
put ' file &fref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjsref clear; ';
|
||||||
|
put ' ';
|
||||||
put '%end; ';
|
put '%end; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put '%mend mm_webout; ';
|
put '%mend mm_webout; ';
|
||||||
@@ -15422,7 +15500,7 @@ run;
|
|||||||
%if &x>1 %then %let mod=mod;
|
%if &x>1 %then %let mod=mod;
|
||||||
|
|
||||||
%let fref=%scan(&freflist,&x);
|
%let fref=%scan(&freflist,&x);
|
||||||
%put &sysmacroname: adding &fref;
|
%&mD.put &sysmacroname: adding &fref;
|
||||||
data _null_;
|
data _null_;
|
||||||
file "&work/&tmpfile" lrecl=3000 &mod;
|
file "&work/&tmpfile" lrecl=3000 &mod;
|
||||||
infile &fref;
|
infile &fref;
|
||||||
@@ -15458,13 +15536,11 @@ data _null_;
|
|||||||
if rc=0 then call symputx('url',url,'l');
|
if rc=0 then call symputx('url',url,'l');
|
||||||
run;
|
run;
|
||||||
|
|
||||||
%put ;%put ;%put ;%put ;%put ;%put ;
|
|
||||||
%put &sysmacroname: STP &name successfully created in &path;
|
%put &sysmacroname: STP &name successfully created in &path;
|
||||||
%put ;%put ;%put ;
|
|
||||||
%put Check it out here:;
|
%put Check it out here:;
|
||||||
%put ;%put ;%put ;
|
%put ;%put ;%put ;
|
||||||
%put &url?_PROGRAM=&path/&name;
|
%put &url?_PROGRAM=&path/&name;
|
||||||
%put ;%put ;%put ;%put ;%put ;%put ;
|
%put ;%put ;%put ;
|
||||||
|
|
||||||
%mend mm_createwebservice;
|
%mend mm_createwebservice;
|
||||||
/**
|
/**
|
||||||
@@ -17228,7 +17304,7 @@ data _null_;
|
|||||||
cnt=1;
|
cnt=1;
|
||||||
do while (metadata_getnasn(uri,"Notes",cnt,tsuri)>0);
|
do while (metadata_getnasn(uri,"Notes",cnt,tsuri)>0);
|
||||||
rc=metadata_getattr(tsuri,"Name",value);
|
rc=metadata_getattr(tsuri,"Name",value);
|
||||||
put tsuri= value=;
|
&mD.put tsuri= value=;
|
||||||
if value="SourceCode" then do;
|
if value="SourceCode" then do;
|
||||||
/* found it! */
|
/* found it! */
|
||||||
rc=metadata_getattr(tsuri,"Id",value);
|
rc=metadata_getattr(tsuri,"Id",value);
|
||||||
@@ -17783,17 +17859,18 @@ libname _XML_ clear;
|
|||||||
|
|
||||||
%mm_getusers()
|
%mm_getusers()
|
||||||
|
|
||||||
|
Optionally, filter for a user (useful to get the uri):
|
||||||
|
|
||||||
|
%mm_getusers(user=&_metaperson)
|
||||||
|
|
||||||
@param outds the dataset to create that contains the list of libraries
|
@param outds the dataset to create that contains the list of libraries
|
||||||
|
|
||||||
@returns outds dataset containing all users, with the following columns:
|
@returns outds dataset containing all users, with the following columns:
|
||||||
- uri
|
- uri
|
||||||
- name
|
- name
|
||||||
|
|
||||||
@warning The following filenames are created and then de-assigned:
|
@param user= (0) Set to a metadata user to filter on that user
|
||||||
|
@param outds= (work.mm_getusers) The output table to create
|
||||||
filename sxlemap clear;
|
|
||||||
filename response clear;
|
|
||||||
libname _XML_ clear;
|
|
||||||
|
|
||||||
@version 9.3
|
@version 9.3
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
@@ -17801,10 +17878,12 @@ libname _XML_ clear;
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
%macro mm_getusers(
|
%macro mm_getusers(
|
||||||
outds=work.mm_getusers
|
outds=work.mm_getusers,
|
||||||
|
user=0
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
filename response temp;
|
filename response temp;
|
||||||
|
%if %superq(user)=0 %then %do;
|
||||||
proc metadata in= '<GetMetadataObjects>
|
proc metadata in= '<GetMetadataObjects>
|
||||||
<Reposid>$METAREPOSITORY</Reposid>
|
<Reposid>$METAREPOSITORY</Reposid>
|
||||||
<Type>Person</Type>
|
<Type>Person</Type>
|
||||||
@@ -17818,6 +17897,30 @@ proc metadata in= '<GetMetadataObjects>
|
|||||||
</GetMetadataObjects>'
|
</GetMetadataObjects>'
|
||||||
out=response;
|
out=response;
|
||||||
run;
|
run;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
filename inref temp;
|
||||||
|
data _null_;
|
||||||
|
file inref;
|
||||||
|
put "<GetMetadataObjects>";
|
||||||
|
put "<Reposid>$METAREPOSITORY</Reposid>";
|
||||||
|
put "<Type>Person</Type>";
|
||||||
|
put "<NS>SAS</NS>";
|
||||||
|
put "<!-- Specify the OMI_XMLSELECT (128) flag -->";
|
||||||
|
put "<Flags>128</Flags>";
|
||||||
|
put "<Options>";
|
||||||
|
put "<Templates>";
|
||||||
|
put '<Person Name=""/>';
|
||||||
|
put "</Templates>";
|
||||||
|
length string $10000;
|
||||||
|
string=cats('<XMLSELECT search="Person[@Name=',"'&user'",']"/>');
|
||||||
|
put string;
|
||||||
|
put "</Options>";
|
||||||
|
put "</GetMetadataObjects>";
|
||||||
|
run;
|
||||||
|
proc metadata in=inref out=response;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
filename sxlemap temp;
|
filename sxlemap temp;
|
||||||
data _null_;
|
data _null_;
|
||||||
@@ -18657,7 +18760,9 @@ data _null_;
|
|||||||
cnt=1;
|
cnt=1;
|
||||||
do while (metadata_getnasn(uri,"Notes",cnt,tsuri)>0);
|
do while (metadata_getnasn(uri,"Notes",cnt,tsuri)>0);
|
||||||
rc=metadata_getattr(tsuri,"Name",value);
|
rc=metadata_getattr(tsuri,"Name",value);
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
put tsuri= value=;
|
put tsuri= value=;
|
||||||
|
%end;
|
||||||
if value="SourceCode" then do;
|
if value="SourceCode" then do;
|
||||||
/* found it! */
|
/* found it! */
|
||||||
rc=metadata_getattr(tsuri,"Id",value);
|
rc=metadata_getattr(tsuri,"Id",value);
|
||||||
@@ -18740,7 +18845,8 @@ run;
|
|||||||
filename &frefout clear;
|
filename &frefout clear;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%mend mm_updatestpsourcecode;/**
|
%mend mm_updatestpsourcecode;
|
||||||
|
/**
|
||||||
@file mm_webout.sas
|
@file mm_webout.sas
|
||||||
@brief Send data to/from SAS Stored Processes
|
@brief Send data to/from SAS Stored Processes
|
||||||
@details This macro should be added to the start of each Stored Process,
|
@details This macro should be added to the start of each Stored Process,
|
||||||
@@ -18777,6 +18883,10 @@ run;
|
|||||||
object with the same name as the table but prefixed with a dollar sign - ie,
|
object with the same name as the table but prefixed with a dollar sign - ie,
|
||||||
`,"$tablename":{"formats":{"col1":"$CHAR1"},"types":{"COL1":"C"}}`
|
`,"$tablename":{"formats":{"col1":"$CHAR1"},"types":{"COL1":"C"}}`
|
||||||
|
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mp_jsonout.sas
|
||||||
|
|
||||||
@version 9.3
|
@version 9.3
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
|
|
||||||
@@ -18853,6 +18963,8 @@ run;
|
|||||||
)
|
)
|
||||||
%end;
|
%end;
|
||||||
%else %if &action=CLOSE %then %do;
|
%else %if &action=CLOSE %then %do;
|
||||||
|
/* To avoid issues with _webout on EBI we use a temporary file */
|
||||||
|
filename _sjsref temp lrecl=131068;
|
||||||
%if %str(&_debug) ge 131 %then %do;
|
%if %str(&_debug) ge 131 %then %do;
|
||||||
/* if debug mode, send back first 10 records of each work table also */
|
/* if debug mode, send back first 10 records of each work table also */
|
||||||
options obs=10;
|
options obs=10;
|
||||||
@@ -18866,11 +18978,11 @@ run;
|
|||||||
i+1;
|
i+1;
|
||||||
call symputx(cats('wt',i),name,'l');
|
call symputx(cats('wt',i),name,'l');
|
||||||
call symputx('wtcnt',i,'l');
|
call symputx('wtcnt',i,'l');
|
||||||
data _null_; file &fref mod encoding='utf-8';
|
data _null_; file _sjsref 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;
|
||||||
data _null_; file &fref mod encoding='utf-8';
|
data _null_; file _sjsref 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');
|
||||||
@@ -18879,16 +18991,16 @@ run;
|
|||||||
put " ""&wt"" : {";
|
put " ""&wt"" : {";
|
||||||
put '"nlobs":' nlobs;
|
put '"nlobs":' nlobs;
|
||||||
put ',"nvars":' nvars;
|
put ',"nvars":' nvars;
|
||||||
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=YES)
|
%mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=YES)
|
||||||
data _null_; file &fref mod encoding='utf-8';
|
data _null_; file _sjsref mod encoding='utf-8';
|
||||||
put "}";
|
put "}";
|
||||||
%end;
|
%end;
|
||||||
data _null_; file &fref mod encoding='utf-8';
|
data _null_; file _sjsref mod encoding='utf-8';
|
||||||
put "}";
|
put "}";
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
/* close off json */
|
/* close off json */
|
||||||
data _null_;file &fref mod encoding='utf-8';
|
data _null_;file _sjsref mod encoding='utf-8';
|
||||||
_PROGRAM=quote(trim(resolve(symget('_PROGRAM'))));
|
_PROGRAM=quote(trim(resolve(symget('_PROGRAM'))));
|
||||||
put ",""SYSUSERID"" : ""&sysuserid"" ";
|
put ",""SYSUSERID"" : ""&sysuserid"" ";
|
||||||
put ",""MF_GETUSER"" : ""%mf_getuser()"" ";
|
put ",""MF_GETUSER"" : ""%mf_getuser()"" ";
|
||||||
@@ -18899,6 +19011,7 @@ run;
|
|||||||
put ',"_METAPERSON": ' _METAPERSON;
|
put ',"_METAPERSON": ' _METAPERSON;
|
||||||
put ',"_PROGRAM" : ' _PROGRAM ;
|
put ',"_PROGRAM" : ' _PROGRAM ;
|
||||||
put ",""SYSCC"" : ""&syscc"" ";
|
put ",""SYSCC"" : ""&syscc"" ";
|
||||||
|
put ",""SYSENCODING"" : ""&sysencoding"" ";
|
||||||
syserrortext=quote(cats(symget('SYSERRORTEXT')));
|
syserrortext=quote(cats(symget('SYSERRORTEXT')));
|
||||||
put ',"SYSERRORTEXT" : ' syserrortext;
|
put ',"SYSERRORTEXT" : ' syserrortext;
|
||||||
put ",""SYSHOSTNAME"" : ""&syshostname"" ";
|
put ",""SYSHOSTNAME"" : ""&syshostname"" ";
|
||||||
@@ -18919,6 +19032,16 @@ run;
|
|||||||
put '>>weboutEND<<';
|
put '>>weboutEND<<';
|
||||||
%end;
|
%end;
|
||||||
run;
|
run;
|
||||||
|
/* now write to _webout 1 char at a time */
|
||||||
|
data _null_;
|
||||||
|
infile _sjsref lrecl=1 recfm=n;
|
||||||
|
file &fref mod lrecl=1 recfm=n;
|
||||||
|
input sourcechar $char1. @@;
|
||||||
|
format sourcechar hex2.;
|
||||||
|
put sourcechar char1. @@;
|
||||||
|
run;
|
||||||
|
filename _sjsref clear;
|
||||||
|
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%mend mm_webout;
|
%mend mm_webout;
|
||||||
@@ -19747,9 +19870,23 @@ data _null_;
|
|||||||
put ' run; ';
|
put ' run; ';
|
||||||
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 ' /* force variable names to always be uppercase in the JSON */ ';
|
||||||
put ' options validvarname=upcase; ';
|
put ' options validvarname=upcase; ';
|
||||||
put ' data _null_; file &jref encoding=''utf-8'' mod; ';
|
put ' /* To avoid issues with _webout on EBI - such as encoding diffs and truncation ';
|
||||||
|
put ' (https://support.sas.com/kb/49/325.html) we use temporary files */ ';
|
||||||
|
put ' filename _sjs1 temp lrecl=200 ; ';
|
||||||
|
put ' data _null_; file _sjs1 encoding=''utf-8''; ';
|
||||||
put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
|
put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' /* now write to _webout 1 char at a time */ ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs1 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs1 clear; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' /* grab col defs */ ';
|
put ' /* grab col defs */ ';
|
||||||
put ' proc contents noprint data=&ds ';
|
put ' proc contents noprint data=&ds ';
|
||||||
@@ -19806,10 +19943,20 @@ data _null_;
|
|||||||
put ' data &tempds;set &ds; ';
|
put ' data &tempds;set &ds; ';
|
||||||
put ' %if &fmt=N %then format _numeric_ best32.;; ';
|
put ' %if &fmt=N %then format _numeric_ best32.;; ';
|
||||||
put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
|
put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
|
||||||
put ' proc json out=&jref pretty ';
|
put ' filename _sjs2 temp lrecl=131068 encoding=''utf-8''; ';
|
||||||
|
put ' proc json out=_sjs2 pretty ';
|
||||||
put ' %if &action=ARR %then nokeys ; ';
|
put ' %if &action=ARR %then nokeys ; ';
|
||||||
put ' ;export &tempds / nosastags fmtnumeric; ';
|
put ' ;export &tempds / nosastags fmtnumeric; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
|
put ' /* send back to webout */ ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs2 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs2 clear; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' %else %if &engine=DATASTEP %then %do; ';
|
put ' %else %if &engine=DATASTEP %then %do; ';
|
||||||
put ' %datastep: ';
|
put ' %datastep: ';
|
||||||
@@ -19892,10 +20039,9 @@ data _null_;
|
|||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' /* write to temp loc to avoid _webout truncation ';
|
put ' filename _sjs3 temp lrecl=131068 ; ';
|
||||||
put ' - https://support.sas.com/kb/49/325.html */ ';
|
put ' data _null_; ';
|
||||||
put ' filename _sjs temp lrecl=131068 encoding=''utf-8''; ';
|
put ' file _sjs3 encoding=''utf-8''; ';
|
||||||
put ' data _null_; file _sjs lrecl=131068 encoding=''utf-8'' mod ; ';
|
|
||||||
put ' if _n_=1 then put "["; ';
|
put ' if _n_=1 then put "["; ';
|
||||||
put ' set &tempds; ';
|
put ' set &tempds; ';
|
||||||
put ' if _n_>1 then put "," @; put ';
|
put ' if _n_>1 then put "," @; put ';
|
||||||
@@ -19906,36 +20052,34 @@ data _null_;
|
|||||||
put ' "&&name&i"n /* name literal for reserved variable names */ ';
|
put ' "&&name&i"n /* name literal for reserved variable names */ ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
||||||
put ' /* now write the long strings to _webout 1 byte at a time */ ';
|
put ' ';
|
||||||
put ' data _null_; ';
|
|
||||||
put ' length filein 8 fileid 8; ';
|
|
||||||
put ' filein=fopen("_sjs",''I'',1,''B''); ';
|
|
||||||
put ' fileid=fopen("&jref",''A'',1,''B''); ';
|
|
||||||
put ' rec=''20''x; ';
|
|
||||||
put ' do while(fread(filein)=0); ';
|
|
||||||
put ' rc=fget(filein,rec,1); ';
|
|
||||||
put ' rc=fput(fileid, rec); ';
|
|
||||||
put ' rc=fwrite(fileid); ';
|
|
||||||
put ' end; ';
|
|
||||||
put ' /* close out the table */ ';
|
put ' /* close out the table */ ';
|
||||||
put ' rc=fput(fileid, "]"); ';
|
put ' data _null_; ';
|
||||||
put ' rc=fwrite(fileid); ';
|
put ' file _sjs3 mod encoding=''utf-8''; ';
|
||||||
put ' rc=fclose(filein); ';
|
put ' put '']''; ';
|
||||||
put ' rc=fclose(fileid); ';
|
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
put ' filename _sjs clear; ';
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs3 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs3 clear; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' proc sql; ';
|
put ' proc sql; ';
|
||||||
put ' drop table &colinfo, &tempds; ';
|
put ' drop table &colinfo, &tempds; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' %if &showmeta=YES %then %do; ';
|
put ' %if &showmeta=YES %then %do; ';
|
||||||
put ' data _null_; file &jref encoding=''utf-8'' mod; ';
|
put ' filename _sjs4 temp lrecl=131068 encoding=''utf-8''; ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' file _sjs4; ';
|
||||||
put ' put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{"; ';
|
put ' put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{"; ';
|
||||||
put ' do i=1 to &numcols; ';
|
put ' do i=1 to &numcols; ';
|
||||||
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
||||||
put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
|
put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
|
||||||
put ' label=quote(trim(symget(cats(''label'',i)))); ';
|
put ' label=quote(prxchange(''s/\\/\\\\/'',-1,trim(symget(cats(''label'',i))))); ';
|
||||||
put ' length=quote(trim(symget(cats(''length'',i)))); ';
|
put ' length=quote(trim(symget(cats(''length'',i)))); ';
|
||||||
put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
|
put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
|
||||||
put ' if i>1 then put "," @@; ';
|
put ' if i>1 then put "," @@; ';
|
||||||
@@ -19944,6 +20088,15 @@ data _null_;
|
|||||||
put ' end; ';
|
put ' end; ';
|
||||||
put ' put ''}}''; ';
|
put ' put ''}}''; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
|
put ' /* send back to webout */ ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs4 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs4 clear; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put '%end; ';
|
put '%end; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
@@ -20081,6 +20234,7 @@ data _null_;
|
|||||||
put ' put ",""_DEBUG"" : ""&_debug"" "; ';
|
put ' put ",""_DEBUG"" : ""&_debug"" "; ';
|
||||||
put ' put '',"_PROGRAM" : '' _PROGRAM ; ';
|
put ' put '',"_PROGRAM" : '' _PROGRAM ; ';
|
||||||
put ' put ",""SYSCC"" : ""&syscc"" "; ';
|
put ' put ",""SYSCC"" : ""&syscc"" "; ';
|
||||||
|
put ' put ",""SYSENCODING"" : ""&sysencoding"" "; ';
|
||||||
put ' syserrortext=quote(cats(symget(''SYSERRORTEXT''))); ';
|
put ' syserrortext=quote(cats(symget(''SYSERRORTEXT''))); ';
|
||||||
put ' put '',"SYSERRORTEXT" : '' syserrortext; ';
|
put ' put '',"SYSERRORTEXT" : '' syserrortext; ';
|
||||||
put ' SYSHOSTINFOLONG=quote(trim(symget(''SYSHOSTINFOLONG''))); ';
|
put ' SYSHOSTINFOLONG=quote(trim(symget(''SYSHOSTINFOLONG''))); ';
|
||||||
@@ -21070,6 +21224,7 @@ run;
|
|||||||
put ",""_DEBUG"" : ""&_debug"" ";
|
put ",""_DEBUG"" : ""&_debug"" ";
|
||||||
put ',"_PROGRAM" : ' _PROGRAM ;
|
put ',"_PROGRAM" : ' _PROGRAM ;
|
||||||
put ",""SYSCC"" : ""&syscc"" ";
|
put ",""SYSCC"" : ""&syscc"" ";
|
||||||
|
put ",""SYSENCODING"" : ""&sysencoding"" ";
|
||||||
syserrortext=quote(cats(symget('SYSERRORTEXT')));
|
syserrortext=quote(cats(symget('SYSERRORTEXT')));
|
||||||
put ',"SYSERRORTEXT" : ' syserrortext;
|
put ',"SYSERRORTEXT" : ' syserrortext;
|
||||||
SYSHOSTINFOLONG=quote(trim(symget('SYSHOSTINFOLONG')));
|
SYSHOSTINFOLONG=quote(trim(symget('SYSHOSTINFOLONG')));
|
||||||
@@ -22090,9 +22245,23 @@ data _null_;
|
|||||||
put ' run; ';
|
put ' run; ';
|
||||||
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 ' /* force variable names to always be uppercase in the JSON */ ';
|
||||||
put ' options validvarname=upcase; ';
|
put ' options validvarname=upcase; ';
|
||||||
put ' data _null_; file &jref encoding=''utf-8'' mod; ';
|
put ' /* To avoid issues with _webout on EBI - such as encoding diffs and truncation ';
|
||||||
|
put ' (https://support.sas.com/kb/49/325.html) we use temporary files */ ';
|
||||||
|
put ' filename _sjs1 temp lrecl=200 ; ';
|
||||||
|
put ' data _null_; file _sjs1 encoding=''utf-8''; ';
|
||||||
put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
|
put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' /* now write to _webout 1 char at a time */ ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs1 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs1 clear; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' /* grab col defs */ ';
|
put ' /* grab col defs */ ';
|
||||||
put ' proc contents noprint data=&ds ';
|
put ' proc contents noprint data=&ds ';
|
||||||
@@ -22149,10 +22318,20 @@ data _null_;
|
|||||||
put ' data &tempds;set &ds; ';
|
put ' data &tempds;set &ds; ';
|
||||||
put ' %if &fmt=N %then format _numeric_ best32.;; ';
|
put ' %if &fmt=N %then format _numeric_ best32.;; ';
|
||||||
put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
|
put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
|
||||||
put ' proc json out=&jref pretty ';
|
put ' filename _sjs2 temp lrecl=131068 encoding=''utf-8''; ';
|
||||||
|
put ' proc json out=_sjs2 pretty ';
|
||||||
put ' %if &action=ARR %then nokeys ; ';
|
put ' %if &action=ARR %then nokeys ; ';
|
||||||
put ' ;export &tempds / nosastags fmtnumeric; ';
|
put ' ;export &tempds / nosastags fmtnumeric; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
|
put ' /* send back to webout */ ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs2 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs2 clear; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' %else %if &engine=DATASTEP %then %do; ';
|
put ' %else %if &engine=DATASTEP %then %do; ';
|
||||||
put ' %datastep: ';
|
put ' %datastep: ';
|
||||||
@@ -22235,10 +22414,9 @@ data _null_;
|
|||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' /* write to temp loc to avoid _webout truncation ';
|
put ' filename _sjs3 temp lrecl=131068 ; ';
|
||||||
put ' - https://support.sas.com/kb/49/325.html */ ';
|
put ' data _null_; ';
|
||||||
put ' filename _sjs temp lrecl=131068 encoding=''utf-8''; ';
|
put ' file _sjs3 encoding=''utf-8''; ';
|
||||||
put ' data _null_; file _sjs lrecl=131068 encoding=''utf-8'' mod ; ';
|
|
||||||
put ' if _n_=1 then put "["; ';
|
put ' if _n_=1 then put "["; ';
|
||||||
put ' set &tempds; ';
|
put ' set &tempds; ';
|
||||||
put ' if _n_>1 then put "," @; put ';
|
put ' if _n_>1 then put "," @; put ';
|
||||||
@@ -22249,36 +22427,34 @@ data _null_;
|
|||||||
put ' "&&name&i"n /* name literal for reserved variable names */ ';
|
put ' "&&name&i"n /* name literal for reserved variable names */ ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
||||||
put ' /* now write the long strings to _webout 1 byte at a time */ ';
|
put ' ';
|
||||||
put ' data _null_; ';
|
|
||||||
put ' length filein 8 fileid 8; ';
|
|
||||||
put ' filein=fopen("_sjs",''I'',1,''B''); ';
|
|
||||||
put ' fileid=fopen("&jref",''A'',1,''B''); ';
|
|
||||||
put ' rec=''20''x; ';
|
|
||||||
put ' do while(fread(filein)=0); ';
|
|
||||||
put ' rc=fget(filein,rec,1); ';
|
|
||||||
put ' rc=fput(fileid, rec); ';
|
|
||||||
put ' rc=fwrite(fileid); ';
|
|
||||||
put ' end; ';
|
|
||||||
put ' /* close out the table */ ';
|
put ' /* close out the table */ ';
|
||||||
put ' rc=fput(fileid, "]"); ';
|
put ' data _null_; ';
|
||||||
put ' rc=fwrite(fileid); ';
|
put ' file _sjs3 mod encoding=''utf-8''; ';
|
||||||
put ' rc=fclose(filein); ';
|
put ' put '']''; ';
|
||||||
put ' rc=fclose(fileid); ';
|
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
put ' filename _sjs clear; ';
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs3 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs3 clear; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' proc sql; ';
|
put ' proc sql; ';
|
||||||
put ' drop table &colinfo, &tempds; ';
|
put ' drop table &colinfo, &tempds; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' %if &showmeta=YES %then %do; ';
|
put ' %if &showmeta=YES %then %do; ';
|
||||||
put ' data _null_; file &jref encoding=''utf-8'' mod; ';
|
put ' filename _sjs4 temp lrecl=131068 encoding=''utf-8''; ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' file _sjs4; ';
|
||||||
put ' put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{"; ';
|
put ' put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{"; ';
|
||||||
put ' do i=1 to &numcols; ';
|
put ' do i=1 to &numcols; ';
|
||||||
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
||||||
put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
|
put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
|
||||||
put ' label=quote(trim(symget(cats(''label'',i)))); ';
|
put ' label=quote(prxchange(''s/\\/\\\\/'',-1,trim(symget(cats(''label'',i))))); ';
|
||||||
put ' length=quote(trim(symget(cats(''length'',i)))); ';
|
put ' length=quote(trim(symget(cats(''length'',i)))); ';
|
||||||
put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
|
put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
|
||||||
put ' if i>1 then put "," @@; ';
|
put ' if i>1 then put "," @@; ';
|
||||||
@@ -22287,6 +22463,15 @@ data _null_;
|
|||||||
put ' end; ';
|
put ' end; ';
|
||||||
put ' put ''}}''; ';
|
put ' put ''}}''; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
|
put ' /* send back to webout */ ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs4 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs4 clear; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put '%end; ';
|
put '%end; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
|
|||||||
@@ -8,8 +8,10 @@
|
|||||||
|
|
||||||
The method used varies according to the context. Important points:
|
The method used varies according to the context. Important points:
|
||||||
|
|
||||||
@li should not use endsas or abort cancel in 9.4m3 environments as this can
|
@li should not use endsas or abort cancel in 9.4m3 WIN environments as this
|
||||||
cause hung multibridge sessions and result in a frozen STP server
|
can cause hung multibridge sessions and result in a frozen STP server
|
||||||
|
@li The use of endsas in 9.4m6+ windows environments for POST requests to the
|
||||||
|
STP server can result in an empty response body
|
||||||
@li should not use endsas in viya 3.5 as this destroys the session and cannot
|
@li should not use endsas in viya 3.5 as this destroys the session and cannot
|
||||||
fetch results (although both mv_getjoblog.sas and the @sasjs/adapter will
|
fetch results (although both mv_getjoblog.sas and the @sasjs/adapter will
|
||||||
recognise this and fetch the log of the parent session instead)
|
recognise this and fetch the log of the parent session instead)
|
||||||
@@ -21,8 +23,8 @@
|
|||||||
a macro. For that, we recommend you use mp_include.sas to perform the
|
a macro. For that, we recommend you use mp_include.sas to perform the
|
||||||
include, and then call \%mp_abort(mode=INCLUDE) from the source program (ie,
|
include, and then call \%mp_abort(mode=INCLUDE) from the source program (ie,
|
||||||
OUTSIDE of the top-parent macro).
|
OUTSIDE of the top-parent macro).
|
||||||
The soft abort has also been found to be ineffective in 9.4m6 windows
|
The soft abort has become ineffective in 9.4m6 WINDOWS environments. We are
|
||||||
environments and above, so in these cases, endsas is used.
|
currently investigating approaches to deal with this.
|
||||||
|
|
||||||
|
|
||||||
@param mac= (mp_abort.sas) To contain the name of the calling macro. Do not
|
@param mac= (mp_abort.sas) To contain the name of the calling macro. Do not
|
||||||
@@ -63,7 +65,7 @@
|
|||||||
, mode=REGULAR
|
, mode=REGULAR
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
%global sysprocessmode sysprocessname sasjs_stpsrv_header_loc;
|
%global sysprocessmode sysprocessname sasjs_stpsrv_header_loc sasjsprocessmode;
|
||||||
%local fref fid i;
|
%local fref fid i;
|
||||||
|
|
||||||
%if not(%eval(%unquote(&iftrue))) %then %return;
|
%if not(%eval(%unquote(&iftrue))) %then %return;
|
||||||
@@ -247,6 +249,7 @@
|
|||||||
call symputx("syscc",0,"g");
|
call symputx("syscc",0,"g");
|
||||||
run;
|
run;
|
||||||
%if &sysscp=WIN
|
%if &sysscp=WIN
|
||||||
|
and 1=0 /* deprecating this logic until we figure out a consistent abort */
|
||||||
and "%substr(%str(&sysvlong ),1,8)"="9.04.01M"
|
and "%substr(%str(&sysvlong ),1,8)"="9.04.01M"
|
||||||
and "%substr(%str(&sysvlong ),9,1)">"5" %then %do;
|
and "%substr(%str(&sysvlong ),9,1)">"5" %then %do;
|
||||||
/* skip approach (below) does not work in windows m6+ envs */
|
/* skip approach (below) does not work in windows m6+ envs */
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
@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
|
||||||
os-independent method to copy files. In case of naming collision, the
|
os-independent method to copy files. In case of naming collision, the
|
||||||
default filerefs can be modified.
|
default filerefs can be modified.
|
||||||
Based on:
|
Note that if you have a new enough version of SAS, and you don't need features
|
||||||
https://stackoverflow.com/questions/13046116/using-sas-to-copy-a-text-file
|
such as APPEND, you may be better of using the fcopy() function instead.
|
||||||
|
|
||||||
%mp_binarycopy(inloc="/home/me/blah.txt", outref=_webout)
|
%mp_binarycopy(inloc="/home/me/blah.txt", outref=_webout)
|
||||||
|
|
||||||
@@ -45,14 +45,9 @@
|
|||||||
,outref=____out /* override default to use own filerefs */
|
,outref=____out /* override default to use own filerefs */
|
||||||
,mode=CREATE
|
,mode=CREATE
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
%local mod outmode;
|
%local mod;
|
||||||
%if &mode=APPEND %then %do;
|
%if &mode=APPEND %then %let mod=mod;
|
||||||
%let mod=mod;
|
|
||||||
%let outmode='a';
|
|
||||||
%end;
|
|
||||||
%else %do;
|
|
||||||
%let outmode='o';
|
|
||||||
%end;
|
|
||||||
/* these IN and OUT filerefs can point to anything */
|
/* these IN and OUT filerefs can point to anything */
|
||||||
%if &inref = ____in %then %do;
|
%if &inref = ____in %then %do;
|
||||||
filename &inref &inloc lrecl=1048576 ;
|
filename &inref &inloc lrecl=1048576 ;
|
||||||
@@ -63,18 +58,13 @@
|
|||||||
|
|
||||||
/* copy the file byte-for-byte */
|
/* copy the file byte-for-byte */
|
||||||
data _null_;
|
data _null_;
|
||||||
length filein 8 fileid 8;
|
infile &inref lrecl=1 recfm=n;
|
||||||
filein = fopen("&inref",'I',1,'B');
|
file &outref &mod recfm=n;
|
||||||
fileid = fopen("&outref",&outmode,1,'B');
|
input sourcechar $char1. @@;
|
||||||
rec = '20'x;
|
format sourcechar hex2.;
|
||||||
do while(fread(filein)=0);
|
put sourcechar char1. @@;
|
||||||
rc = fget(filein,rec,1);
|
|
||||||
rc = fput(fileid, rec);
|
|
||||||
rc =fwrite(fileid);
|
|
||||||
end;
|
|
||||||
rc = fclose(filein);
|
|
||||||
rc = fclose(fileid);
|
|
||||||
run;
|
run;
|
||||||
|
|
||||||
%if &inref = ____in %then %do;
|
%if &inref = ____in %then %do;
|
||||||
filename &inref clear;
|
filename &inref clear;
|
||||||
%end;
|
%end;
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
@cond
|
@cond
|
||||||
**/
|
**/
|
||||||
|
|
||||||
%macro mp_ds2cards(base_ds=, tgt_ds=
|
%macro mp_ds2cards(base_ds, tgt_ds=
|
||||||
,cards_file="%sysfunc(pathname(work))/cardgen.sas"
|
,cards_file="%sysfunc(pathname(work))/cardgen.sas"
|
||||||
,maxobs=max
|
,maxobs=max
|
||||||
,random_sample=NO
|
,random_sample=NO
|
||||||
@@ -254,6 +254,7 @@ data _null_;
|
|||||||
;
|
;
|
||||||
%end;
|
%end;
|
||||||
put ";";
|
put ";";
|
||||||
|
put 'missing a b c d e f g h i j k l m n o p q r s t u v w x y z _;';
|
||||||
put "datalines4;";
|
put "datalines4;";
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
@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 This macro can be used to OPEN a JSON stream and send one or more
|
||||||
|
tables as arrays of rows, where each row can be an object or a nested array.
|
||||||
|
|
||||||
|
There are two engines available - DATASTEP or PROCJSON.
|
||||||
|
|
||||||
|
PROC JSON is fast but will produce errs like the ones below if
|
||||||
special chars are encountered.
|
special chars are encountered.
|
||||||
|
|
||||||
> (ERR)OR: Some code points did not transcode.
|
> (ERR)OR: Some code points did not transcode.
|
||||||
@@ -12,6 +17,10 @@
|
|||||||
|
|
||||||
If this happens, try running with ENGINE=DATASTEP.
|
If this happens, try running with ENGINE=DATASTEP.
|
||||||
|
|
||||||
|
The DATASTEP engine is used to handle special SAS missing numerics, and
|
||||||
|
can also convert entire datasets to formatted values. Output JSON is always
|
||||||
|
in UTF-8.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
filename tmp temp;
|
filename tmp temp;
|
||||||
@@ -75,9 +84,23 @@
|
|||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
%else %if (&action=ARR or &action=OBJ) %then %do;
|
%else %if (&action=ARR or &action=OBJ) %then %do;
|
||||||
|
/* force variable names to always be uppercase in the JSON */
|
||||||
options validvarname=upcase;
|
options validvarname=upcase;
|
||||||
data _null_; file &jref encoding='utf-8' mod;
|
/* To avoid issues with _webout on EBI - such as encoding diffs and truncation
|
||||||
|
(https://support.sas.com/kb/49/325.html) we use temporary files */
|
||||||
|
filename _sjs1 temp lrecl=200 ;
|
||||||
|
data _null_; file _sjs1 encoding='utf-8';
|
||||||
put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":";
|
put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":";
|
||||||
|
run;
|
||||||
|
/* now write to _webout 1 char at a time */
|
||||||
|
data _null_;
|
||||||
|
infile _sjs1 lrecl=1 recfm=n;
|
||||||
|
file &jref mod lrecl=1 recfm=n;
|
||||||
|
input sourcechar $char1. @@;
|
||||||
|
format sourcechar hex2.;
|
||||||
|
put sourcechar char1. @@;
|
||||||
|
run;
|
||||||
|
filename _sjs1 clear;
|
||||||
|
|
||||||
/* grab col defs */
|
/* grab col defs */
|
||||||
proc contents noprint data=&ds
|
proc contents noprint data=&ds
|
||||||
@@ -134,10 +157,20 @@
|
|||||||
data &tempds;set &ds;
|
data &tempds;set &ds;
|
||||||
%if &fmt=N %then format _numeric_ best32.;;
|
%if &fmt=N %then format _numeric_ best32.;;
|
||||||
/* PRETTY is necessary to avoid line truncation in large files */
|
/* PRETTY is necessary to avoid line truncation in large files */
|
||||||
proc json out=&jref pretty
|
filename _sjs2 temp lrecl=131068 encoding='utf-8';
|
||||||
|
proc json out=_sjs2 pretty
|
||||||
%if &action=ARR %then nokeys ;
|
%if &action=ARR %then nokeys ;
|
||||||
;export &tempds / nosastags fmtnumeric;
|
;export &tempds / nosastags fmtnumeric;
|
||||||
run;
|
run;
|
||||||
|
/* send back to webout */
|
||||||
|
data _null_;
|
||||||
|
infile _sjs2 lrecl=1 recfm=n;
|
||||||
|
file &jref mod lrecl=1 recfm=n;
|
||||||
|
input sourcechar $char1. @@;
|
||||||
|
format sourcechar hex2.;
|
||||||
|
put sourcechar char1. @@;
|
||||||
|
run;
|
||||||
|
filename _sjs2 clear;
|
||||||
%end;
|
%end;
|
||||||
%else %if &engine=DATASTEP %then %do;
|
%else %if &engine=DATASTEP %then %do;
|
||||||
%datastep:
|
%datastep:
|
||||||
@@ -220,10 +253,9 @@
|
|||||||
%end;
|
%end;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
/* write to temp loc to avoid _webout truncation
|
filename _sjs3 temp lrecl=131068 ;
|
||||||
- https://support.sas.com/kb/49/325.html */
|
data _null_;
|
||||||
filename _sjs temp lrecl=131068 encoding='utf-8';
|
file _sjs3 encoding='utf-8';
|
||||||
data _null_; file _sjs lrecl=131068 encoding='utf-8' mod ;
|
|
||||||
if _n_=1 then put "[";
|
if _n_=1 then put "[";
|
||||||
set &tempds;
|
set &tempds;
|
||||||
if _n_>1 then put "," @; put
|
if _n_>1 then put "," @; put
|
||||||
@@ -234,36 +266,34 @@
|
|||||||
"&&name&i"n /* name literal for reserved variable names */
|
"&&name&i"n /* name literal for reserved variable names */
|
||||||
%end;
|
%end;
|
||||||
%if &action=ARR %then "]" ; %else "}" ; ;
|
%if &action=ARR %then "]" ; %else "}" ; ;
|
||||||
/* now write the long strings to _webout 1 byte at a time */
|
|
||||||
data _null_;
|
|
||||||
length filein 8 fileid 8;
|
|
||||||
filein=fopen("_sjs",'I',1,'B');
|
|
||||||
fileid=fopen("&jref",'A',1,'B');
|
|
||||||
rec='20'x;
|
|
||||||
do while(fread(filein)=0);
|
|
||||||
rc=fget(filein,rec,1);
|
|
||||||
rc=fput(fileid, rec);
|
|
||||||
rc=fwrite(fileid);
|
|
||||||
end;
|
|
||||||
/* close out the table */
|
/* close out the table */
|
||||||
rc=fput(fileid, "]");
|
data _null_;
|
||||||
rc=fwrite(fileid);
|
file _sjs3 mod encoding='utf-8';
|
||||||
rc=fclose(filein);
|
put ']';
|
||||||
rc=fclose(fileid);
|
|
||||||
run;
|
run;
|
||||||
filename _sjs clear;
|
data _null_;
|
||||||
|
infile _sjs3 lrecl=1 recfm=n;
|
||||||
|
file &jref mod lrecl=1 recfm=n;
|
||||||
|
input sourcechar $char1. @@;
|
||||||
|
format sourcechar hex2.;
|
||||||
|
put sourcechar char1. @@;
|
||||||
|
run;
|
||||||
|
filename _sjs3 clear;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
proc sql;
|
proc sql;
|
||||||
drop table &colinfo, &tempds;
|
drop table &colinfo, &tempds;
|
||||||
|
|
||||||
%if &showmeta=YES %then %do;
|
%if &showmeta=YES %then %do;
|
||||||
data _null_; file &jref encoding='utf-8' mod;
|
filename _sjs4 temp lrecl=131068 encoding='utf-8';
|
||||||
|
data _null_;
|
||||||
|
file _sjs4;
|
||||||
put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{";
|
put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{";
|
||||||
do i=1 to &numcols;
|
do i=1 to &numcols;
|
||||||
name=quote(trim(symget(cats('name',i))));
|
name=quote(trim(symget(cats('name',i))));
|
||||||
format=quote(trim(symget(cats('fmt',i))));
|
format=quote(trim(symget(cats('fmt',i))));
|
||||||
label=quote(trim(symget(cats('label',i))));
|
label=quote(prxchange('s/\\/\\\\/',-1,trim(symget(cats('label',i)))));
|
||||||
length=quote(trim(symget(cats('length',i))));
|
length=quote(trim(symget(cats('length',i))));
|
||||||
type=quote(trim(symget(cats('typelong',i))));
|
type=quote(trim(symget(cats('typelong',i))));
|
||||||
if i>1 then put "," @@;
|
if i>1 then put "," @@;
|
||||||
@@ -272,6 +302,15 @@
|
|||||||
end;
|
end;
|
||||||
put '}}';
|
put '}}';
|
||||||
run;
|
run;
|
||||||
|
/* send back to webout */
|
||||||
|
data _null_;
|
||||||
|
infile _sjs4 lrecl=1 recfm=n;
|
||||||
|
file &jref mod lrecl=1 recfm=n;
|
||||||
|
input sourcechar $char1. @@;
|
||||||
|
format sourcechar hex2.;
|
||||||
|
put sourcechar char1. @@;
|
||||||
|
run;
|
||||||
|
filename _sjs4 clear;
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
%mm_createfolder(path=/some/meta/folder)
|
%mm_createfolder(path=/some/meta/folder)
|
||||||
|
|
||||||
@param [in] path= Name of the folder to create.
|
@param [in] path= Name of the folder to create.
|
||||||
@param [in] mdebug= set DBG to 1 to disable DEBUG messages
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
|
|
||||||
|
|
||||||
@version 9.4
|
@version 9.4
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
@file mm_createwebservice.sas
|
@file mm_createwebservice.sas
|
||||||
@brief Create a Web Ready Stored Process
|
@brief Create a Web Ready Stored Process
|
||||||
@details This macro creates a Type 2 Stored Process with the mm_webout macro
|
@details This macro creates a Type 2 Stored Process with the mm_webout macro
|
||||||
included as pre-code.
|
(and dependencies) included as pre-code.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
%* compile macros ;
|
%* compile macros ;
|
||||||
@@ -108,9 +109,23 @@ data _null_;
|
|||||||
put ' run; ';
|
put ' run; ';
|
||||||
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 ' /* force variable names to always be uppercase in the JSON */ ';
|
||||||
put ' options validvarname=upcase; ';
|
put ' options validvarname=upcase; ';
|
||||||
put ' data _null_; file &jref encoding=''utf-8'' mod; ';
|
put ' /* To avoid issues with _webout on EBI - such as encoding diffs and truncation ';
|
||||||
|
put ' (https://support.sas.com/kb/49/325.html) we use temporary files */ ';
|
||||||
|
put ' filename _sjs1 temp lrecl=200 ; ';
|
||||||
|
put ' data _null_; file _sjs1 encoding=''utf-8''; ';
|
||||||
put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
|
put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' /* now write to _webout 1 char at a time */ ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs1 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs1 clear; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' /* grab col defs */ ';
|
put ' /* grab col defs */ ';
|
||||||
put ' proc contents noprint data=&ds ';
|
put ' proc contents noprint data=&ds ';
|
||||||
@@ -167,10 +182,20 @@ data _null_;
|
|||||||
put ' data &tempds;set &ds; ';
|
put ' data &tempds;set &ds; ';
|
||||||
put ' %if &fmt=N %then format _numeric_ best32.;; ';
|
put ' %if &fmt=N %then format _numeric_ best32.;; ';
|
||||||
put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
|
put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
|
||||||
put ' proc json out=&jref pretty ';
|
put ' filename _sjs2 temp lrecl=131068 encoding=''utf-8''; ';
|
||||||
|
put ' proc json out=_sjs2 pretty ';
|
||||||
put ' %if &action=ARR %then nokeys ; ';
|
put ' %if &action=ARR %then nokeys ; ';
|
||||||
put ' ;export &tempds / nosastags fmtnumeric; ';
|
put ' ;export &tempds / nosastags fmtnumeric; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
|
put ' /* send back to webout */ ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs2 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs2 clear; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' %else %if &engine=DATASTEP %then %do; ';
|
put ' %else %if &engine=DATASTEP %then %do; ';
|
||||||
put ' %datastep: ';
|
put ' %datastep: ';
|
||||||
@@ -253,10 +278,9 @@ data _null_;
|
|||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' /* write to temp loc to avoid _webout truncation ';
|
put ' filename _sjs3 temp lrecl=131068 ; ';
|
||||||
put ' - https://support.sas.com/kb/49/325.html */ ';
|
put ' data _null_; ';
|
||||||
put ' filename _sjs temp lrecl=131068 encoding=''utf-8''; ';
|
put ' file _sjs3 encoding=''utf-8''; ';
|
||||||
put ' data _null_; file _sjs lrecl=131068 encoding=''utf-8'' mod ; ';
|
|
||||||
put ' if _n_=1 then put "["; ';
|
put ' if _n_=1 then put "["; ';
|
||||||
put ' set &tempds; ';
|
put ' set &tempds; ';
|
||||||
put ' if _n_>1 then put "," @; put ';
|
put ' if _n_>1 then put "," @; put ';
|
||||||
@@ -267,36 +291,34 @@ data _null_;
|
|||||||
put ' "&&name&i"n /* name literal for reserved variable names */ ';
|
put ' "&&name&i"n /* name literal for reserved variable names */ ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
||||||
put ' /* now write the long strings to _webout 1 byte at a time */ ';
|
put ' ';
|
||||||
put ' data _null_; ';
|
|
||||||
put ' length filein 8 fileid 8; ';
|
|
||||||
put ' filein=fopen("_sjs",''I'',1,''B''); ';
|
|
||||||
put ' fileid=fopen("&jref",''A'',1,''B''); ';
|
|
||||||
put ' rec=''20''x; ';
|
|
||||||
put ' do while(fread(filein)=0); ';
|
|
||||||
put ' rc=fget(filein,rec,1); ';
|
|
||||||
put ' rc=fput(fileid, rec); ';
|
|
||||||
put ' rc=fwrite(fileid); ';
|
|
||||||
put ' end; ';
|
|
||||||
put ' /* close out the table */ ';
|
put ' /* close out the table */ ';
|
||||||
put ' rc=fput(fileid, "]"); ';
|
put ' data _null_; ';
|
||||||
put ' rc=fwrite(fileid); ';
|
put ' file _sjs3 mod encoding=''utf-8''; ';
|
||||||
put ' rc=fclose(filein); ';
|
put ' put '']''; ';
|
||||||
put ' rc=fclose(fileid); ';
|
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
put ' filename _sjs clear; ';
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs3 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs3 clear; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' proc sql; ';
|
put ' proc sql; ';
|
||||||
put ' drop table &colinfo, &tempds; ';
|
put ' drop table &colinfo, &tempds; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' %if &showmeta=YES %then %do; ';
|
put ' %if &showmeta=YES %then %do; ';
|
||||||
put ' data _null_; file &jref encoding=''utf-8'' mod; ';
|
put ' filename _sjs4 temp lrecl=131068 encoding=''utf-8''; ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' file _sjs4; ';
|
||||||
put ' put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{"; ';
|
put ' put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{"; ';
|
||||||
put ' do i=1 to &numcols; ';
|
put ' do i=1 to &numcols; ';
|
||||||
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
||||||
put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
|
put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
|
||||||
put ' label=quote(trim(symget(cats(''label'',i)))); ';
|
put ' label=quote(prxchange(''s/\\/\\\\/'',-1,trim(symget(cats(''label'',i))))); ';
|
||||||
put ' length=quote(trim(symget(cats(''length'',i)))); ';
|
put ' length=quote(trim(symget(cats(''length'',i)))); ';
|
||||||
put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
|
put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
|
||||||
put ' if i>1 then put "," @@; ';
|
put ' if i>1 then put "," @@; ';
|
||||||
@@ -305,6 +327,15 @@ data _null_;
|
|||||||
put ' end; ';
|
put ' end; ';
|
||||||
put ' put ''}}''; ';
|
put ' put ''}}''; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
|
put ' /* send back to webout */ ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs4 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs4 clear; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put '%end; ';
|
put '%end; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
@@ -406,6 +437,8 @@ data _null_;
|
|||||||
put ' ) ';
|
put ' ) ';
|
||||||
put '%end; ';
|
put '%end; ';
|
||||||
put '%else %if &action=CLOSE %then %do; ';
|
put '%else %if &action=CLOSE %then %do; ';
|
||||||
|
put ' /* To avoid issues with _webout on EBI we use a temporary file */ ';
|
||||||
|
put ' filename _sjsref temp lrecl=131068; ';
|
||||||
put ' %if %str(&_debug) ge 131 %then %do; ';
|
put ' %if %str(&_debug) ge 131 %then %do; ';
|
||||||
put ' /* if debug mode, send back first 10 records of each work table also */ ';
|
put ' /* if debug mode, send back first 10 records of each work table also */ ';
|
||||||
put ' options obs=10; ';
|
put ' options obs=10; ';
|
||||||
@@ -419,11 +452,11 @@ data _null_;
|
|||||||
put ' i+1; ';
|
put ' i+1; ';
|
||||||
put ' call symputx(cats(''wt'',i),name,''l''); ';
|
put ' call symputx(cats(''wt'',i),name,''l''); ';
|
||||||
put ' call symputx(''wtcnt'',i,''l''); ';
|
put ' call symputx(''wtcnt'',i,''l''); ';
|
||||||
put ' data _null_; file &fref mod encoding=''utf-8''; ';
|
put ' data _null_; file _sjsref 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 ' data _null_; file &fref mod encoding=''utf-8''; ';
|
put ' data _null_; file _sjsref 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''); ';
|
||||||
@@ -432,16 +465,16 @@ data _null_;
|
|||||||
put ' put " ""&wt"" : {"; ';
|
put ' put " ""&wt"" : {"; ';
|
||||||
put ' put ''"nlobs":'' nlobs; ';
|
put ' put ''"nlobs":'' nlobs; ';
|
||||||
put ' put '',"nvars":'' nvars; ';
|
put ' put '',"nvars":'' nvars; ';
|
||||||
put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=YES) ';
|
put ' %mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=YES) ';
|
||||||
put ' data _null_; file &fref mod encoding=''utf-8''; ';
|
put ' data _null_; file _sjsref mod encoding=''utf-8''; ';
|
||||||
put ' put "}"; ';
|
put ' put "}"; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' data _null_; file &fref mod encoding=''utf-8''; ';
|
put ' data _null_; file _sjsref mod encoding=''utf-8''; ';
|
||||||
put ' put "}"; ';
|
put ' put "}"; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' /* close off json */ ';
|
put ' /* close off json */ ';
|
||||||
put ' data _null_;file &fref mod encoding=''utf-8''; ';
|
put ' data _null_;file _sjsref mod encoding=''utf-8''; ';
|
||||||
put ' _PROGRAM=quote(trim(resolve(symget(''_PROGRAM'')))); ';
|
put ' _PROGRAM=quote(trim(resolve(symget(''_PROGRAM'')))); ';
|
||||||
put ' put ",""SYSUSERID"" : ""&sysuserid"" "; ';
|
put ' put ",""SYSUSERID"" : ""&sysuserid"" "; ';
|
||||||
put ' put ",""MF_GETUSER"" : ""%mf_getuser()"" "; ';
|
put ' put ",""MF_GETUSER"" : ""%mf_getuser()"" "; ';
|
||||||
@@ -452,6 +485,7 @@ data _null_;
|
|||||||
put ' put '',"_METAPERSON": '' _METAPERSON; ';
|
put ' put '',"_METAPERSON": '' _METAPERSON; ';
|
||||||
put ' put '',"_PROGRAM" : '' _PROGRAM ; ';
|
put ' put '',"_PROGRAM" : '' _PROGRAM ; ';
|
||||||
put ' put ",""SYSCC"" : ""&syscc"" "; ';
|
put ' put ",""SYSCC"" : ""&syscc"" "; ';
|
||||||
|
put ' put ",""SYSENCODING"" : ""&sysencoding"" "; ';
|
||||||
put ' syserrortext=quote(cats(symget(''SYSERRORTEXT''))); ';
|
put ' syserrortext=quote(cats(symget(''SYSERRORTEXT''))); ';
|
||||||
put ' put '',"SYSERRORTEXT" : '' syserrortext; ';
|
put ' put '',"SYSERRORTEXT" : '' syserrortext; ';
|
||||||
put ' put ",""SYSHOSTNAME"" : ""&syshostname"" "; ';
|
put ' put ",""SYSHOSTNAME"" : ""&syshostname"" "; ';
|
||||||
@@ -472,6 +506,16 @@ data _null_;
|
|||||||
put ' put ''>>weboutEND<<''; ';
|
put ' put ''>>weboutEND<<''; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
|
put ' /* now write to _webout 1 char at a time */ ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjsref lrecl=1 recfm=n; ';
|
||||||
|
put ' file &fref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjsref clear; ';
|
||||||
|
put ' ';
|
||||||
put '%end; ';
|
put '%end; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put '%mend mm_webout; ';
|
put '%mend mm_webout; ';
|
||||||
@@ -493,7 +537,7 @@ run;
|
|||||||
%if &x>1 %then %let mod=mod;
|
%if &x>1 %then %let mod=mod;
|
||||||
|
|
||||||
%let fref=%scan(&freflist,&x);
|
%let fref=%scan(&freflist,&x);
|
||||||
%put &sysmacroname: adding &fref;
|
%&mD.put &sysmacroname: adding &fref;
|
||||||
data _null_;
|
data _null_;
|
||||||
file "&work/&tmpfile" lrecl=3000 &mod;
|
file "&work/&tmpfile" lrecl=3000 &mod;
|
||||||
infile &fref;
|
infile &fref;
|
||||||
@@ -529,12 +573,10 @@ data _null_;
|
|||||||
if rc=0 then call symputx('url',url,'l');
|
if rc=0 then call symputx('url',url,'l');
|
||||||
run;
|
run;
|
||||||
|
|
||||||
%put ;%put ;%put ;%put ;%put ;%put ;
|
|
||||||
%put &sysmacroname: STP &name successfully created in &path;
|
%put &sysmacroname: STP &name successfully created in &path;
|
||||||
%put ;%put ;%put ;
|
|
||||||
%put Check it out here:;
|
%put Check it out here:;
|
||||||
%put ;%put ;%put ;
|
%put ;%put ;%put ;
|
||||||
%put &url?_PROGRAM=&path/&name;
|
%put &url?_PROGRAM=&path/&name;
|
||||||
%put ;%put ;%put ;%put ;%put ;%put ;
|
%put ;%put ;%put ;
|
||||||
|
|
||||||
%mend mm_createwebservice;
|
%mend mm_createwebservice;
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ data _null_;
|
|||||||
cnt=1;
|
cnt=1;
|
||||||
do while (metadata_getnasn(uri,"Notes",cnt,tsuri)>0);
|
do while (metadata_getnasn(uri,"Notes",cnt,tsuri)>0);
|
||||||
rc=metadata_getattr(tsuri,"Name",value);
|
rc=metadata_getattr(tsuri,"Name",value);
|
||||||
put tsuri= value=;
|
&mD.put tsuri= value=;
|
||||||
if value="SourceCode" then do;
|
if value="SourceCode" then do;
|
||||||
/* found it! */
|
/* found it! */
|
||||||
rc=metadata_getattr(tsuri,"Id",value);
|
rc=metadata_getattr(tsuri,"Id",value);
|
||||||
|
|||||||
@@ -8,17 +8,18 @@
|
|||||||
|
|
||||||
%mm_getusers()
|
%mm_getusers()
|
||||||
|
|
||||||
|
Optionally, filter for a user (useful to get the uri):
|
||||||
|
|
||||||
|
%mm_getusers(user=&_metaperson)
|
||||||
|
|
||||||
@param outds the dataset to create that contains the list of libraries
|
@param outds the dataset to create that contains the list of libraries
|
||||||
|
|
||||||
@returns outds dataset containing all users, with the following columns:
|
@returns outds dataset containing all users, with the following columns:
|
||||||
- uri
|
- uri
|
||||||
- name
|
- name
|
||||||
|
|
||||||
@warning The following filenames are created and then de-assigned:
|
@param user= (0) Set to a metadata user to filter on that user
|
||||||
|
@param outds= (work.mm_getusers) The output table to create
|
||||||
filename sxlemap clear;
|
|
||||||
filename response clear;
|
|
||||||
libname _XML_ clear;
|
|
||||||
|
|
||||||
@version 9.3
|
@version 9.3
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
@@ -26,10 +27,12 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
%macro mm_getusers(
|
%macro mm_getusers(
|
||||||
outds=work.mm_getusers
|
outds=work.mm_getusers,
|
||||||
|
user=0
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
filename response temp;
|
filename response temp;
|
||||||
|
%if %superq(user)=0 %then %do;
|
||||||
proc metadata in= '<GetMetadataObjects>
|
proc metadata in= '<GetMetadataObjects>
|
||||||
<Reposid>$METAREPOSITORY</Reposid>
|
<Reposid>$METAREPOSITORY</Reposid>
|
||||||
<Type>Person</Type>
|
<Type>Person</Type>
|
||||||
@@ -43,6 +46,30 @@ proc metadata in= '<GetMetadataObjects>
|
|||||||
</GetMetadataObjects>'
|
</GetMetadataObjects>'
|
||||||
out=response;
|
out=response;
|
||||||
run;
|
run;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
filename inref temp;
|
||||||
|
data _null_;
|
||||||
|
file inref;
|
||||||
|
put "<GetMetadataObjects>";
|
||||||
|
put "<Reposid>$METAREPOSITORY</Reposid>";
|
||||||
|
put "<Type>Person</Type>";
|
||||||
|
put "<NS>SAS</NS>";
|
||||||
|
put "<!-- Specify the OMI_XMLSELECT (128) flag -->";
|
||||||
|
put "<Flags>128</Flags>";
|
||||||
|
put "<Options>";
|
||||||
|
put "<Templates>";
|
||||||
|
put '<Person Name=""/>';
|
||||||
|
put "</Templates>";
|
||||||
|
length string $10000;
|
||||||
|
string=cats('<XMLSELECT search="Person[@Name=',"'&user'",']"/>');
|
||||||
|
put string;
|
||||||
|
put "</Options>";
|
||||||
|
put "</GetMetadataObjects>";
|
||||||
|
run;
|
||||||
|
proc metadata in=inref out=response;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
filename sxlemap temp;
|
filename sxlemap temp;
|
||||||
data _null_;
|
data _null_;
|
||||||
|
|||||||
@@ -43,7 +43,9 @@ data _null_;
|
|||||||
cnt=1;
|
cnt=1;
|
||||||
do while (metadata_getnasn(uri,"Notes",cnt,tsuri)>0);
|
do while (metadata_getnasn(uri,"Notes",cnt,tsuri)>0);
|
||||||
rc=metadata_getattr(tsuri,"Name",value);
|
rc=metadata_getattr(tsuri,"Name",value);
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
put tsuri= value=;
|
put tsuri= value=;
|
||||||
|
%end;
|
||||||
if value="SourceCode" then do;
|
if value="SourceCode" then do;
|
||||||
/* found it! */
|
/* found it! */
|
||||||
rc=metadata_getattr(tsuri,"Id",value);
|
rc=metadata_getattr(tsuri,"Id",value);
|
||||||
|
|||||||
@@ -35,6 +35,10 @@
|
|||||||
object with the same name as the table but prefixed with a dollar sign - ie,
|
object with the same name as the table but prefixed with a dollar sign - ie,
|
||||||
`,"$tablename":{"formats":{"col1":"$CHAR1"},"types":{"COL1":"C"}}`
|
`,"$tablename":{"formats":{"col1":"$CHAR1"},"types":{"COL1":"C"}}`
|
||||||
|
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mp_jsonout.sas
|
||||||
|
|
||||||
@version 9.3
|
@version 9.3
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
|
|
||||||
@@ -111,6 +115,8 @@
|
|||||||
)
|
)
|
||||||
%end;
|
%end;
|
||||||
%else %if &action=CLOSE %then %do;
|
%else %if &action=CLOSE %then %do;
|
||||||
|
/* To avoid issues with _webout on EBI we use a temporary file */
|
||||||
|
filename _sjsref temp lrecl=131068;
|
||||||
%if %str(&_debug) ge 131 %then %do;
|
%if %str(&_debug) ge 131 %then %do;
|
||||||
/* if debug mode, send back first 10 records of each work table also */
|
/* if debug mode, send back first 10 records of each work table also */
|
||||||
options obs=10;
|
options obs=10;
|
||||||
@@ -124,11 +130,11 @@
|
|||||||
i+1;
|
i+1;
|
||||||
call symputx(cats('wt',i),name,'l');
|
call symputx(cats('wt',i),name,'l');
|
||||||
call symputx('wtcnt',i,'l');
|
call symputx('wtcnt',i,'l');
|
||||||
data _null_; file &fref mod encoding='utf-8';
|
data _null_; file _sjsref 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;
|
||||||
data _null_; file &fref mod encoding='utf-8';
|
data _null_; file _sjsref 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');
|
||||||
@@ -137,16 +143,16 @@
|
|||||||
put " ""&wt"" : {";
|
put " ""&wt"" : {";
|
||||||
put '"nlobs":' nlobs;
|
put '"nlobs":' nlobs;
|
||||||
put ',"nvars":' nvars;
|
put ',"nvars":' nvars;
|
||||||
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=YES)
|
%mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=YES)
|
||||||
data _null_; file &fref mod encoding='utf-8';
|
data _null_; file _sjsref mod encoding='utf-8';
|
||||||
put "}";
|
put "}";
|
||||||
%end;
|
%end;
|
||||||
data _null_; file &fref mod encoding='utf-8';
|
data _null_; file _sjsref mod encoding='utf-8';
|
||||||
put "}";
|
put "}";
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
/* close off json */
|
/* close off json */
|
||||||
data _null_;file &fref mod encoding='utf-8';
|
data _null_;file _sjsref mod encoding='utf-8';
|
||||||
_PROGRAM=quote(trim(resolve(symget('_PROGRAM'))));
|
_PROGRAM=quote(trim(resolve(symget('_PROGRAM'))));
|
||||||
put ",""SYSUSERID"" : ""&sysuserid"" ";
|
put ",""SYSUSERID"" : ""&sysuserid"" ";
|
||||||
put ",""MF_GETUSER"" : ""%mf_getuser()"" ";
|
put ",""MF_GETUSER"" : ""%mf_getuser()"" ";
|
||||||
@@ -157,6 +163,7 @@
|
|||||||
put ',"_METAPERSON": ' _METAPERSON;
|
put ',"_METAPERSON": ' _METAPERSON;
|
||||||
put ',"_PROGRAM" : ' _PROGRAM ;
|
put ',"_PROGRAM" : ' _PROGRAM ;
|
||||||
put ",""SYSCC"" : ""&syscc"" ";
|
put ",""SYSCC"" : ""&syscc"" ";
|
||||||
|
put ",""SYSENCODING"" : ""&sysencoding"" ";
|
||||||
syserrortext=quote(cats(symget('SYSERRORTEXT')));
|
syserrortext=quote(cats(symget('SYSERRORTEXT')));
|
||||||
put ',"SYSERRORTEXT" : ' syserrortext;
|
put ',"SYSERRORTEXT" : ' syserrortext;
|
||||||
put ",""SYSHOSTNAME"" : ""&syshostname"" ";
|
put ",""SYSHOSTNAME"" : ""&syshostname"" ";
|
||||||
@@ -177,6 +184,16 @@
|
|||||||
put '>>weboutEND<<';
|
put '>>weboutEND<<';
|
||||||
%end;
|
%end;
|
||||||
run;
|
run;
|
||||||
|
/* now write to _webout 1 char at a time */
|
||||||
|
data _null_;
|
||||||
|
infile _sjsref lrecl=1 recfm=n;
|
||||||
|
file &fref mod lrecl=1 recfm=n;
|
||||||
|
input sourcechar $char1. @@;
|
||||||
|
format sourcechar hex2.;
|
||||||
|
put sourcechar char1. @@;
|
||||||
|
run;
|
||||||
|
filename _sjsref clear;
|
||||||
|
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%mend mm_webout;
|
%mend mm_webout;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "server",
|
"name": "server",
|
||||||
"serverUrl": "https://sas.4gl.io",
|
"serverUrl": "",
|
||||||
"serverType": "SASJS",
|
"serverType": "SASJS",
|
||||||
"httpsAgentOptions": {
|
"httpsAgentOptions": {
|
||||||
"allowInsecureRequests": false
|
"allowInsecureRequests": false
|
||||||
|
|||||||
@@ -110,9 +110,23 @@ data _null_;
|
|||||||
put ' run; ';
|
put ' run; ';
|
||||||
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 ' /* force variable names to always be uppercase in the JSON */ ';
|
||||||
put ' options validvarname=upcase; ';
|
put ' options validvarname=upcase; ';
|
||||||
put ' data _null_; file &jref encoding=''utf-8'' mod; ';
|
put ' /* To avoid issues with _webout on EBI - such as encoding diffs and truncation ';
|
||||||
|
put ' (https://support.sas.com/kb/49/325.html) we use temporary files */ ';
|
||||||
|
put ' filename _sjs1 temp lrecl=200 ; ';
|
||||||
|
put ' data _null_; file _sjs1 encoding=''utf-8''; ';
|
||||||
put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
|
put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' /* now write to _webout 1 char at a time */ ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs1 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs1 clear; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' /* grab col defs */ ';
|
put ' /* grab col defs */ ';
|
||||||
put ' proc contents noprint data=&ds ';
|
put ' proc contents noprint data=&ds ';
|
||||||
@@ -169,10 +183,20 @@ data _null_;
|
|||||||
put ' data &tempds;set &ds; ';
|
put ' data &tempds;set &ds; ';
|
||||||
put ' %if &fmt=N %then format _numeric_ best32.;; ';
|
put ' %if &fmt=N %then format _numeric_ best32.;; ';
|
||||||
put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
|
put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
|
||||||
put ' proc json out=&jref pretty ';
|
put ' filename _sjs2 temp lrecl=131068 encoding=''utf-8''; ';
|
||||||
|
put ' proc json out=_sjs2 pretty ';
|
||||||
put ' %if &action=ARR %then nokeys ; ';
|
put ' %if &action=ARR %then nokeys ; ';
|
||||||
put ' ;export &tempds / nosastags fmtnumeric; ';
|
put ' ;export &tempds / nosastags fmtnumeric; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
|
put ' /* send back to webout */ ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs2 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs2 clear; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' %else %if &engine=DATASTEP %then %do; ';
|
put ' %else %if &engine=DATASTEP %then %do; ';
|
||||||
put ' %datastep: ';
|
put ' %datastep: ';
|
||||||
@@ -255,10 +279,9 @@ data _null_;
|
|||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' /* write to temp loc to avoid _webout truncation ';
|
put ' filename _sjs3 temp lrecl=131068 ; ';
|
||||||
put ' - https://support.sas.com/kb/49/325.html */ ';
|
put ' data _null_; ';
|
||||||
put ' filename _sjs temp lrecl=131068 encoding=''utf-8''; ';
|
put ' file _sjs3 encoding=''utf-8''; ';
|
||||||
put ' data _null_; file _sjs lrecl=131068 encoding=''utf-8'' mod ; ';
|
|
||||||
put ' if _n_=1 then put "["; ';
|
put ' if _n_=1 then put "["; ';
|
||||||
put ' set &tempds; ';
|
put ' set &tempds; ';
|
||||||
put ' if _n_>1 then put "," @; put ';
|
put ' if _n_>1 then put "," @; put ';
|
||||||
@@ -269,36 +292,34 @@ data _null_;
|
|||||||
put ' "&&name&i"n /* name literal for reserved variable names */ ';
|
put ' "&&name&i"n /* name literal for reserved variable names */ ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
||||||
put ' /* now write the long strings to _webout 1 byte at a time */ ';
|
put ' ';
|
||||||
put ' data _null_; ';
|
|
||||||
put ' length filein 8 fileid 8; ';
|
|
||||||
put ' filein=fopen("_sjs",''I'',1,''B''); ';
|
|
||||||
put ' fileid=fopen("&jref",''A'',1,''B''); ';
|
|
||||||
put ' rec=''20''x; ';
|
|
||||||
put ' do while(fread(filein)=0); ';
|
|
||||||
put ' rc=fget(filein,rec,1); ';
|
|
||||||
put ' rc=fput(fileid, rec); ';
|
|
||||||
put ' rc=fwrite(fileid); ';
|
|
||||||
put ' end; ';
|
|
||||||
put ' /* close out the table */ ';
|
put ' /* close out the table */ ';
|
||||||
put ' rc=fput(fileid, "]"); ';
|
put ' data _null_; ';
|
||||||
put ' rc=fwrite(fileid); ';
|
put ' file _sjs3 mod encoding=''utf-8''; ';
|
||||||
put ' rc=fclose(filein); ';
|
put ' put '']''; ';
|
||||||
put ' rc=fclose(fileid); ';
|
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
put ' filename _sjs clear; ';
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs3 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs3 clear; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' proc sql; ';
|
put ' proc sql; ';
|
||||||
put ' drop table &colinfo, &tempds; ';
|
put ' drop table &colinfo, &tempds; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' %if &showmeta=YES %then %do; ';
|
put ' %if &showmeta=YES %then %do; ';
|
||||||
put ' data _null_; file &jref encoding=''utf-8'' mod; ';
|
put ' filename _sjs4 temp lrecl=131068 encoding=''utf-8''; ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' file _sjs4; ';
|
||||||
put ' put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{"; ';
|
put ' put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{"; ';
|
||||||
put ' do i=1 to &numcols; ';
|
put ' do i=1 to &numcols; ';
|
||||||
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
||||||
put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
|
put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
|
||||||
put ' label=quote(trim(symget(cats(''label'',i)))); ';
|
put ' label=quote(prxchange(''s/\\/\\\\/'',-1,trim(symget(cats(''label'',i))))); ';
|
||||||
put ' length=quote(trim(symget(cats(''length'',i)))); ';
|
put ' length=quote(trim(symget(cats(''length'',i)))); ';
|
||||||
put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
|
put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
|
||||||
put ' if i>1 then put "," @@; ';
|
put ' if i>1 then put "," @@; ';
|
||||||
@@ -307,6 +328,15 @@ data _null_;
|
|||||||
put ' end; ';
|
put ' end; ';
|
||||||
put ' put ''}}''; ';
|
put ' put ''}}''; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
|
put ' /* send back to webout */ ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs4 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs4 clear; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put '%end; ';
|
put '%end; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
@@ -444,6 +474,7 @@ data _null_;
|
|||||||
put ' put ",""_DEBUG"" : ""&_debug"" "; ';
|
put ' put ",""_DEBUG"" : ""&_debug"" "; ';
|
||||||
put ' put '',"_PROGRAM" : '' _PROGRAM ; ';
|
put ' put '',"_PROGRAM" : '' _PROGRAM ; ';
|
||||||
put ' put ",""SYSCC"" : ""&syscc"" "; ';
|
put ' put ",""SYSCC"" : ""&syscc"" "; ';
|
||||||
|
put ' put ",""SYSENCODING"" : ""&sysencoding"" "; ';
|
||||||
put ' syserrortext=quote(cats(symget(''SYSERRORTEXT''))); ';
|
put ' syserrortext=quote(cats(symget(''SYSERRORTEXT''))); ';
|
||||||
put ' put '',"SYSERRORTEXT" : '' syserrortext; ';
|
put ' put '',"SYSERRORTEXT" : '' syserrortext; ';
|
||||||
put ' SYSHOSTINFOLONG=quote(trim(symget(''SYSHOSTINFOLONG''))); ';
|
put ' SYSHOSTINFOLONG=quote(trim(symget(''SYSHOSTINFOLONG''))); ';
|
||||||
|
|||||||
@@ -153,6 +153,7 @@
|
|||||||
put ",""_DEBUG"" : ""&_debug"" ";
|
put ",""_DEBUG"" : ""&_debug"" ";
|
||||||
put ',"_PROGRAM" : ' _PROGRAM ;
|
put ',"_PROGRAM" : ' _PROGRAM ;
|
||||||
put ",""SYSCC"" : ""&syscc"" ";
|
put ",""SYSCC"" : ""&syscc"" ";
|
||||||
|
put ",""SYSENCODING"" : ""&sysencoding"" ";
|
||||||
syserrortext=quote(cats(symget('SYSERRORTEXT')));
|
syserrortext=quote(cats(symget('SYSERRORTEXT')));
|
||||||
put ',"SYSERRORTEXT" : ' syserrortext;
|
put ',"SYSERRORTEXT" : ' syserrortext;
|
||||||
SYSHOSTINFOLONG=quote(trim(symget('SYSHOSTINFOLONG')));
|
SYSHOSTINFOLONG=quote(trim(symget('SYSHOSTINFOLONG')));
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mp_binarycopy.sas
|
@li mp_binarycopy.sas
|
||||||
@li mp_assert.sas
|
@li mp_assert.sas
|
||||||
|
@li mp_hashdataset.sas
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@@ -97,3 +98,39 @@ run;
|
|||||||
desc=Append Check (ref to file),
|
desc=Append Check (ref to file),
|
||||||
outds=work.test_results
|
outds=work.test_results
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/* test 5 - ensure copy works for binary characters */
|
||||||
|
/* do this backwards to avoid null chars in JSON preview */
|
||||||
|
data work.test5;
|
||||||
|
do i=255 to 1 by -1;
|
||||||
|
str=byte(i);
|
||||||
|
output;
|
||||||
|
end;
|
||||||
|
run;
|
||||||
|
/* get an md5 hash of the ds */
|
||||||
|
%mp_hashdataset(work.test5,outds=myhash)
|
||||||
|
|
||||||
|
/* copy it */
|
||||||
|
%mp_binarycopy(inloc="%sysfunc(pathname(work))/test5.sas7bdat",
|
||||||
|
outloc="%sysfunc(pathname(work))/test5copy.sas7bdat"
|
||||||
|
)
|
||||||
|
|
||||||
|
/* get an md5 hash of the copied ds */
|
||||||
|
%mp_hashdataset(work.test5copy,outds=myhash2)
|
||||||
|
|
||||||
|
/* compare hashes */
|
||||||
|
%let test5a=0;
|
||||||
|
%let test5b=1;
|
||||||
|
data _null_;
|
||||||
|
set myhash;
|
||||||
|
call symputx('test5a',hashkey);
|
||||||
|
run;
|
||||||
|
data _null_;
|
||||||
|
set myhash2;
|
||||||
|
call symputx('test5b',hashkey);
|
||||||
|
run;
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=("&test5a"="&test5b"),
|
||||||
|
desc=Ensuring binary copy works on binary characters,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|||||||
@@ -252,9 +252,23 @@ data _null_;
|
|||||||
put ' run; ';
|
put ' run; ';
|
||||||
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 ' /* force variable names to always be uppercase in the JSON */ ';
|
||||||
put ' options validvarname=upcase; ';
|
put ' options validvarname=upcase; ';
|
||||||
put ' data _null_; file &jref encoding=''utf-8'' mod; ';
|
put ' /* To avoid issues with _webout on EBI - such as encoding diffs and truncation ';
|
||||||
|
put ' (https://support.sas.com/kb/49/325.html) we use temporary files */ ';
|
||||||
|
put ' filename _sjs1 temp lrecl=200 ; ';
|
||||||
|
put ' data _null_; file _sjs1 encoding=''utf-8''; ';
|
||||||
put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
|
put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' /* now write to _webout 1 char at a time */ ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs1 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs1 clear; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' /* grab col defs */ ';
|
put ' /* grab col defs */ ';
|
||||||
put ' proc contents noprint data=&ds ';
|
put ' proc contents noprint data=&ds ';
|
||||||
@@ -311,10 +325,20 @@ data _null_;
|
|||||||
put ' data &tempds;set &ds; ';
|
put ' data &tempds;set &ds; ';
|
||||||
put ' %if &fmt=N %then format _numeric_ best32.;; ';
|
put ' %if &fmt=N %then format _numeric_ best32.;; ';
|
||||||
put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
|
put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
|
||||||
put ' proc json out=&jref pretty ';
|
put ' filename _sjs2 temp lrecl=131068 encoding=''utf-8''; ';
|
||||||
|
put ' proc json out=_sjs2 pretty ';
|
||||||
put ' %if &action=ARR %then nokeys ; ';
|
put ' %if &action=ARR %then nokeys ; ';
|
||||||
put ' ;export &tempds / nosastags fmtnumeric; ';
|
put ' ;export &tempds / nosastags fmtnumeric; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
|
put ' /* send back to webout */ ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs2 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs2 clear; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' %else %if &engine=DATASTEP %then %do; ';
|
put ' %else %if &engine=DATASTEP %then %do; ';
|
||||||
put ' %datastep: ';
|
put ' %datastep: ';
|
||||||
@@ -397,10 +421,9 @@ data _null_;
|
|||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' /* write to temp loc to avoid _webout truncation ';
|
put ' filename _sjs3 temp lrecl=131068 ; ';
|
||||||
put ' - https://support.sas.com/kb/49/325.html */ ';
|
put ' data _null_; ';
|
||||||
put ' filename _sjs temp lrecl=131068 encoding=''utf-8''; ';
|
put ' file _sjs3 encoding=''utf-8''; ';
|
||||||
put ' data _null_; file _sjs lrecl=131068 encoding=''utf-8'' mod ; ';
|
|
||||||
put ' if _n_=1 then put "["; ';
|
put ' if _n_=1 then put "["; ';
|
||||||
put ' set &tempds; ';
|
put ' set &tempds; ';
|
||||||
put ' if _n_>1 then put "," @; put ';
|
put ' if _n_>1 then put "," @; put ';
|
||||||
@@ -411,36 +434,34 @@ data _null_;
|
|||||||
put ' "&&name&i"n /* name literal for reserved variable names */ ';
|
put ' "&&name&i"n /* name literal for reserved variable names */ ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
||||||
put ' /* now write the long strings to _webout 1 byte at a time */ ';
|
put ' ';
|
||||||
put ' data _null_; ';
|
|
||||||
put ' length filein 8 fileid 8; ';
|
|
||||||
put ' filein=fopen("_sjs",''I'',1,''B''); ';
|
|
||||||
put ' fileid=fopen("&jref",''A'',1,''B''); ';
|
|
||||||
put ' rec=''20''x; ';
|
|
||||||
put ' do while(fread(filein)=0); ';
|
|
||||||
put ' rc=fget(filein,rec,1); ';
|
|
||||||
put ' rc=fput(fileid, rec); ';
|
|
||||||
put ' rc=fwrite(fileid); ';
|
|
||||||
put ' end; ';
|
|
||||||
put ' /* close out the table */ ';
|
put ' /* close out the table */ ';
|
||||||
put ' rc=fput(fileid, "]"); ';
|
put ' data _null_; ';
|
||||||
put ' rc=fwrite(fileid); ';
|
put ' file _sjs3 mod encoding=''utf-8''; ';
|
||||||
put ' rc=fclose(filein); ';
|
put ' put '']''; ';
|
||||||
put ' rc=fclose(fileid); ';
|
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
put ' filename _sjs clear; ';
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs3 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs3 clear; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' proc sql; ';
|
put ' proc sql; ';
|
||||||
put ' drop table &colinfo, &tempds; ';
|
put ' drop table &colinfo, &tempds; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' %if &showmeta=YES %then %do; ';
|
put ' %if &showmeta=YES %then %do; ';
|
||||||
put ' data _null_; file &jref encoding=''utf-8'' mod; ';
|
put ' filename _sjs4 temp lrecl=131068 encoding=''utf-8''; ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' file _sjs4; ';
|
||||||
put ' put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{"; ';
|
put ' put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{"; ';
|
||||||
put ' do i=1 to &numcols; ';
|
put ' do i=1 to &numcols; ';
|
||||||
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
||||||
put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
|
put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
|
||||||
put ' label=quote(trim(symget(cats(''label'',i)))); ';
|
put ' label=quote(prxchange(''s/\\/\\\\/'',-1,trim(symget(cats(''label'',i))))); ';
|
||||||
put ' length=quote(trim(symget(cats(''length'',i)))); ';
|
put ' length=quote(trim(symget(cats(''length'',i)))); ';
|
||||||
put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
|
put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
|
||||||
put ' if i>1 then put "," @@; ';
|
put ' if i>1 then put "," @@; ';
|
||||||
@@ -449,6 +470,15 @@ data _null_;
|
|||||||
put ' end; ';
|
put ' end; ';
|
||||||
put ' put ''}}''; ';
|
put ' put ''}}''; ';
|
||||||
put ' run; ';
|
put ' run; ';
|
||||||
|
put ' /* send back to webout */ ';
|
||||||
|
put ' data _null_; ';
|
||||||
|
put ' infile _sjs4 lrecl=1 recfm=n; ';
|
||||||
|
put ' file &jref mod lrecl=1 recfm=n; ';
|
||||||
|
put ' input sourcechar $char1. @@; ';
|
||||||
|
put ' format sourcechar hex2.; ';
|
||||||
|
put ' put sourcechar char1. @@; ';
|
||||||
|
put ' run; ';
|
||||||
|
put ' filename _sjs4 clear; ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put '%end; ';
|
put '%end; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
|
|||||||
Reference in New Issue
Block a user