@sasjs/core 3.7.5 → 3.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/base/mp_jsonout.sas +138 -102
- package/base/mp_lockanytable.sas +1 -1
- package/meta/mm_createstp.sas +11 -8
- package/meta/mm_createwebservice.sas +152 -111
- package/meta/mm_webout.sas +21 -13
- package/package.json +2 -2
- package/server/ms_webout.sas +16 -12
- package/viya/mv_createwebservice.sas +141 -104
- package/viya/mv_webout.sas +23 -15
|
@@ -12,6 +12,7 @@ Usage:
|
|
|
12
12
|
%* parmcards lets us write to a text file from open code ;
|
|
13
13
|
filename ft15f001 temp;
|
|
14
14
|
parmcards4;
|
|
15
|
+
%webout(FETCH)
|
|
15
16
|
%* do some sas, any inputs are now already WORK tables;
|
|
16
17
|
data example1 example2;
|
|
17
18
|
set sashelp.class;
|
|
@@ -24,11 +25,8 @@ Usage:
|
|
|
24
25
|
;;;;
|
|
25
26
|
%mm_createwebservice(path=/Public/app/common,name=appInit,code=ft15f001)
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
@li mf_getuser.sas
|
|
30
|
-
@li mm_createfolder.sas
|
|
31
|
-
@li mm_deletestp.sas
|
|
28
|
+
For more examples of using these web services with the SASjs Adapter, see:
|
|
29
|
+
https://github.com/sasjs/adapter#readme
|
|
32
30
|
|
|
33
31
|
@param path= The full path (in SAS Metadata) where the service will be created
|
|
34
32
|
@param name= Stored Process name. Avoid spaces - testing has shown that
|
|
@@ -37,16 +35,22 @@ Usage:
|
|
|
37
35
|
@param desc= The description of the service (optional)
|
|
38
36
|
@param precode= Space separated list of filerefs, pointing to the code that
|
|
39
37
|
needs to be attached to the beginning of the service (optional)
|
|
40
|
-
@param code=(ft15f001) Space seperated fileref(s) of the actual code to be
|
|
38
|
+
@param code= (ft15f001) Space seperated fileref(s) of the actual code to be
|
|
41
39
|
added
|
|
42
|
-
@param server=(SASApp) The server which will run the STP. Server name or uri
|
|
40
|
+
@param server= (SASApp) The server which will run the STP. Server name or uri
|
|
43
41
|
is fine.
|
|
44
|
-
@param mDebug=(0) set to 1 to show debug messages in the log
|
|
45
|
-
@param replace=(YES) select NO to avoid replacing an existing service in that
|
|
42
|
+
@param mDebug= (0) set to 1 to show debug messages in the log
|
|
43
|
+
@param replace= (YES) select NO to avoid replacing an existing service in that
|
|
46
44
|
location
|
|
47
|
-
@param adapter=(sasjs) the macro uses the sasjs adapter by default. To use
|
|
45
|
+
@param adapter= (sasjs) the macro uses the sasjs adapter by default. To use
|
|
48
46
|
another adapter, add a (different) fileref here.
|
|
49
47
|
|
|
48
|
+
<h4> SAS Macros </h4>
|
|
49
|
+
@li mm_createstp.sas
|
|
50
|
+
@li mf_getuser.sas
|
|
51
|
+
@li mm_createfolder.sas
|
|
52
|
+
@li mm_deletestp.sas
|
|
53
|
+
|
|
50
54
|
@version 9.2
|
|
51
55
|
@author Allan Bowe
|
|
52
56
|
|
|
@@ -89,9 +93,15 @@ data _null_;
|
|
|
89
93
|
put "/* Created on %sysfunc(datetime(),datetime19.) by %mf_getuser() */";
|
|
90
94
|
/* WEBOUT BEGIN */
|
|
91
95
|
put ' ';
|
|
92
|
-
put '%macro mp_jsonout(action,ds,jref=_webout,dslabel=,fmt=Y
|
|
96
|
+
put '%macro mp_jsonout(action,ds,jref=_webout,dslabel=,fmt=Y ';
|
|
97
|
+
put ' ,engine=DATASTEP ';
|
|
98
|
+
put ' ,dbg=0 /* DEPRECATED */ ';
|
|
99
|
+
put ' ,missing=NULL ';
|
|
100
|
+
put ' ,showmeta=NO ';
|
|
93
101
|
put ')/*/STORE SOURCE*/; ';
|
|
94
|
-
put '%
|
|
102
|
+
put '%local tempds colinfo fmtds i numcols; ';
|
|
103
|
+
put '%let numcols=0; ';
|
|
104
|
+
put ' ';
|
|
95
105
|
put '%if &action=OPEN %then %do; ';
|
|
96
106
|
put ' options nobomfile; ';
|
|
97
107
|
put ' data _null_;file &jref encoding=''utf-8'' ; ';
|
|
@@ -100,118 +110,124 @@ data _null_;
|
|
|
100
110
|
put '%end; ';
|
|
101
111
|
put '%else %if (&action=ARR or &action=OBJ) %then %do; ';
|
|
102
112
|
put ' options validvarname=upcase; ';
|
|
103
|
-
put ' data _null_;file &jref
|
|
113
|
+
put ' data _null_; file &jref encoding=''utf-8'' mod; ';
|
|
104
114
|
put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
|
|
105
115
|
put ' ';
|
|
116
|
+
put ' /* grab col defs */ ';
|
|
117
|
+
put ' proc contents noprint data=&ds ';
|
|
118
|
+
put ' out=_data_(keep=name type length format formatl formatd varnum label); ';
|
|
119
|
+
put ' run; ';
|
|
120
|
+
put ' %let colinfo=%scan(&syslast,2,.); ';
|
|
121
|
+
put ' proc sort data=&colinfo; ';
|
|
122
|
+
put ' by varnum; ';
|
|
123
|
+
put ' run; ';
|
|
124
|
+
put ' /* move meta to mac vars */ ';
|
|
125
|
+
put ' data _null_; ';
|
|
126
|
+
put ' if _n_=1 then call symputx(''numcols'',nobs,''l''); ';
|
|
127
|
+
put ' set &colinfo end=last nobs=nobs; ';
|
|
128
|
+
put ' name=upcase(name); ';
|
|
129
|
+
put ' /* fix formats */ ';
|
|
130
|
+
put ' if type=2 or type=6 then do; ';
|
|
131
|
+
put ' typelong=''char''; ';
|
|
132
|
+
put ' length fmt $49.; ';
|
|
133
|
+
put ' if format='''' then fmt=cats(''$'',length,''.''); ';
|
|
134
|
+
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
|
135
|
+
put ' else fmt=cats(format,formatl,''.''); ';
|
|
136
|
+
put ' newlen=max(formatl,length); ';
|
|
137
|
+
put ' end; ';
|
|
138
|
+
put ' else do; ';
|
|
139
|
+
put ' typelong=''num''; ';
|
|
140
|
+
put ' if format='''' then fmt=''best.''; ';
|
|
141
|
+
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
|
142
|
+
put ' else if formatd=0 then fmt=cats(format,formatl,''.''); ';
|
|
143
|
+
put ' else fmt=cats(format,formatl,''.'',formatd); ';
|
|
144
|
+
put ' /* needs to be wide, for datetimes etc */ ';
|
|
145
|
+
put ' newlen=max(length,formatl,24); ';
|
|
146
|
+
put ' end; ';
|
|
147
|
+
put ' /* 32 char unique name */ ';
|
|
148
|
+
put ' newname=''sasjs''!!substr(cats(put(md5(name),$hex32.)),1,27); ';
|
|
149
|
+
put ' ';
|
|
150
|
+
put ' call symputx(cats(''name'',_n_),name,''l''); ';
|
|
151
|
+
put ' call symputx(cats(''newname'',_n_),newname,''l''); ';
|
|
152
|
+
put ' call symputx(cats(''len'',_n_),newlen,''l''); ';
|
|
153
|
+
put ' call symputx(cats(''length'',_n_),length,''l''); ';
|
|
154
|
+
put ' call symputx(cats(''fmt'',_n_),fmt,''l''); ';
|
|
155
|
+
put ' call symputx(cats(''type'',_n_),type,''l''); ';
|
|
156
|
+
put ' call symputx(cats(''typelong'',_n_),typelong,''l''); ';
|
|
157
|
+
put ' call symputx(cats(''label'',_n_),coalescec(label,name),''l''); ';
|
|
158
|
+
put ' run; ';
|
|
159
|
+
put ' ';
|
|
160
|
+
put ' %let tempds=%substr(_%sysfunc(compress(%sysfunc(uuidgen()),-)),1,32); ';
|
|
161
|
+
put ' ';
|
|
106
162
|
put ' %if &engine=PROCJSON %then %do; ';
|
|
107
|
-
put '
|
|
108
|
-
put '
|
|
163
|
+
put ' %if &missing=STRING %then %do; ';
|
|
164
|
+
put ' %put &sysmacroname: Special Missings not supported in proc json.; ';
|
|
165
|
+
put ' %put &sysmacroname: Switching to DATASTEP engine; ';
|
|
166
|
+
put ' %goto datastep; ';
|
|
167
|
+
put ' %end; ';
|
|
109
168
|
put ' data &tempds /view=&tempds;set &ds; ';
|
|
110
169
|
put ' %if &fmt=N %then format _numeric_ best32.;; ';
|
|
170
|
+
put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
|
|
111
171
|
put ' proc json out=&jref pretty ';
|
|
112
172
|
put ' %if &action=ARR %then nokeys ; ';
|
|
113
173
|
put ' ;export &tempds / nosastags fmtnumeric; ';
|
|
114
174
|
put ' run; ';
|
|
115
|
-
put ' proc sql;drop view &tempds; ';
|
|
116
175
|
put ' %end; ';
|
|
117
176
|
put ' %else %if &engine=DATASTEP %then %do; ';
|
|
118
|
-
put ' %
|
|
119
|
-
put ' %
|
|
120
|
-
put ' %
|
|
177
|
+
put ' %datastep: ';
|
|
178
|
+
put ' %if %sysfunc(exist(&ds)) ne 1 & %sysfunc(exist(&ds,VIEW)) ne 1 ';
|
|
179
|
+
put ' %then %do; ';
|
|
121
180
|
put ' %put &sysmacroname: &ds NOT FOUND!!!; ';
|
|
122
181
|
put ' %return; ';
|
|
123
182
|
put ' %end; ';
|
|
124
|
-
put ' %if &fmt=Y %then %do; ';
|
|
125
|
-
put ' %put converting every variable to a formatted variable; ';
|
|
126
|
-
put ' /* see mp_ds2fmtds.sas for source */ ';
|
|
127
|
-
put ' proc contents noprint data=&ds ';
|
|
128
|
-
put ' out=_data_(keep=name type length format formatl formatd varnum); ';
|
|
129
|
-
put ' run; ';
|
|
130
|
-
put ' proc sort; ';
|
|
131
|
-
put ' by varnum; ';
|
|
132
|
-
put ' run; ';
|
|
133
|
-
put ' %local fmtds; ';
|
|
134
|
-
put ' %let fmtds=%scan(&syslast,2,.); ';
|
|
135
|
-
put ' /* prepare formats and varnames */ ';
|
|
136
|
-
put ' data _null_; ';
|
|
137
|
-
put ' if _n_=1 then call symputx(''nobs'',nobs,''l''); ';
|
|
138
|
-
put ' set &fmtds end=last nobs=nobs; ';
|
|
139
|
-
put ' name=upcase(name); ';
|
|
140
|
-
put ' /* fix formats */ ';
|
|
141
|
-
put ' if type=2 or type=6 then do; ';
|
|
142
|
-
put ' length fmt $49.; ';
|
|
143
|
-
put ' if format='''' then fmt=cats(''$'',length,''.''); ';
|
|
144
|
-
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
|
145
|
-
put ' else fmt=cats(format,formatl,''.''); ';
|
|
146
|
-
put ' newlen=max(formatl,length); ';
|
|
147
|
-
put ' end; ';
|
|
148
|
-
put ' else do; ';
|
|
149
|
-
put ' if format='''' then fmt=''best.''; ';
|
|
150
|
-
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
|
151
|
-
put ' else if formatd=0 then fmt=cats(format,formatl,''.''); ';
|
|
152
|
-
put ' else fmt=cats(format,formatl,''.'',formatd); ';
|
|
153
|
-
put ' /* needs to be wide, for datetimes etc */ ';
|
|
154
|
-
put ' newlen=max(length,formatl,24); ';
|
|
155
|
-
put ' end; ';
|
|
156
|
-
put ' /* 32 char unique name */ ';
|
|
157
|
-
put ' newname=''sasjs''!!substr(cats(put(md5(name),$hex32.)),1,27); ';
|
|
158
183
|
put ' ';
|
|
159
|
-
put '
|
|
160
|
-
put '
|
|
161
|
-
put ' call symputx(cats(''len'',_n_),newlen,''l''); ';
|
|
162
|
-
put ' call symputx(cats(''fmt'',_n_),fmt,''l''); ';
|
|
163
|
-
put ' call symputx(cats(''type'',_n_),type,''l''); ';
|
|
164
|
-
put ' run; ';
|
|
165
|
-
put ' data &fmtds; ';
|
|
184
|
+
put ' %if &fmt=Y %then %do; ';
|
|
185
|
+
put ' data _data_; ';
|
|
166
186
|
put ' /* rename on entry */ ';
|
|
167
187
|
put ' set &ds(rename=( ';
|
|
168
|
-
put ' %
|
|
169
|
-
put ' %do i=1 %to &nobs; ';
|
|
188
|
+
put ' %do i=1 %to &numcols; ';
|
|
170
189
|
put ' &&name&i=&&newname&i ';
|
|
171
190
|
put ' %end; ';
|
|
172
191
|
put ' )); ';
|
|
173
|
-
put ' %do i=1 %to &
|
|
192
|
+
put ' %do i=1 %to &numcols; ';
|
|
174
193
|
put ' length &&name&i $&&len&i; ';
|
|
175
194
|
put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
|
|
176
195
|
put ' drop &&newname&i; ';
|
|
177
196
|
put ' %end; ';
|
|
178
197
|
put ' if _error_ then call symputx(''syscc'',1012); ';
|
|
179
198
|
put ' run; ';
|
|
180
|
-
put ' %let
|
|
181
|
-
put ' %end;
|
|
182
|
-
put ' data _null_;file &jref mod encoding=''utf-8'' ; ';
|
|
183
|
-
put ' put "["; call symputx(''cols'',0,''l''); ';
|
|
184
|
-
put ' proc sort ';
|
|
185
|
-
put ' data=sashelp.vcolumn(where=(libname=''WORK'' & memname="%upcase(&ds)")) ';
|
|
186
|
-
put ' out=_data_; ';
|
|
187
|
-
put ' by varnum; ';
|
|
188
|
-
put ' ';
|
|
189
|
-
put ' data _null_; ';
|
|
190
|
-
put ' set _last_ end=last; ';
|
|
191
|
-
put ' call symputx(cats(''name'',_n_),name,''l''); ';
|
|
192
|
-
put ' call symputx(cats(''type'',_n_),type,''l''); ';
|
|
193
|
-
put ' call symputx(cats(''len'',_n_),length,''l''); ';
|
|
194
|
-
put ' if last then call symputx(''cols'',_n_,''l''); ';
|
|
195
|
-
put ' run; ';
|
|
199
|
+
put ' %let fmtds=&syslast; ';
|
|
200
|
+
put ' %end; ';
|
|
196
201
|
put ' ';
|
|
197
202
|
put ' proc format; /* credit yabwon for special null removal */ ';
|
|
198
|
-
put '
|
|
203
|
+
put ' value bart (default=40) ';
|
|
204
|
+
put ' %if &missing=NULL %then %do; ';
|
|
205
|
+
put ' ._ - .z = null ';
|
|
206
|
+
put ' %end; ';
|
|
207
|
+
put ' %else %do; ';
|
|
208
|
+
put ' ._ = [quote()] ';
|
|
209
|
+
put ' . = null ';
|
|
210
|
+
put ' .a - .z = [quote()] ';
|
|
211
|
+
put ' %end; ';
|
|
199
212
|
put ' other = [best.]; ';
|
|
200
213
|
put ' ';
|
|
201
|
-
put ' data;run; %let tempds=&syslast; /* temp table for spesh char management */ ';
|
|
202
|
-
put ' proc sql; drop table &tempds; ';
|
|
203
214
|
put ' data &tempds/view=&tempds; ';
|
|
204
215
|
put ' attrib _all_ label=''''; ';
|
|
205
|
-
put ' %do i=1 %to &
|
|
206
|
-
put ' %if &&
|
|
216
|
+
put ' %do i=1 %to &numcols; ';
|
|
217
|
+
put ' %if &&typelong&i=char or &fmt=Y %then %do; ';
|
|
207
218
|
put ' length &&name&i $32767; ';
|
|
208
219
|
put ' format &&name&i $32767.; ';
|
|
209
220
|
put ' %end; ';
|
|
210
221
|
put ' %end; ';
|
|
211
|
-
put '
|
|
222
|
+
put ' %if &fmt=Y %then %do; ';
|
|
223
|
+
put ' set &fmtds; ';
|
|
224
|
+
put ' %end; ';
|
|
225
|
+
put ' %else %do; ';
|
|
226
|
+
put ' set &ds; ';
|
|
227
|
+
put ' %end; ';
|
|
212
228
|
put ' format _numeric_ bart.; ';
|
|
213
|
-
put ' %do i=1 %to &
|
|
214
|
-
put ' %if &&
|
|
229
|
+
put ' %do i=1 %to &numcols; ';
|
|
230
|
+
put ' %if &&typelong&i=char or &fmt=Y %then %do; ';
|
|
215
231
|
put ' &&name&i=''"''!!trim(prxchange(''s/"/\"/'',-1, ';
|
|
216
232
|
put ' prxchange(''s/''!!''0A''x!!''/\n/'',-1, ';
|
|
217
233
|
put ' prxchange(''s/''!!''0D''x!!''/\r/'',-1, ';
|
|
@@ -221,49 +237,72 @@ data _null_;
|
|
|
221
237
|
put ' %end; ';
|
|
222
238
|
put ' %end; ';
|
|
223
239
|
put ' run; ';
|
|
240
|
+
put ' ';
|
|
224
241
|
put ' /* write to temp loc to avoid _webout truncation ';
|
|
225
242
|
put ' - https://support.sas.com/kb/49/325.html */ ';
|
|
226
243
|
put ' filename _sjs temp lrecl=131068 encoding=''utf-8''; ';
|
|
227
244
|
put ' data _null_; file _sjs lrecl=131068 encoding=''utf-8'' mod ; ';
|
|
245
|
+
put ' if _n_=1 then put "["; ';
|
|
228
246
|
put ' set &tempds; ';
|
|
229
247
|
put ' if _n_>1 then put "," @; put ';
|
|
230
248
|
put ' %if &action=ARR %then "[" ; %else "{" ; ';
|
|
231
|
-
put ' %do i=1 %to &
|
|
249
|
+
put ' %do i=1 %to &numcols; ';
|
|
232
250
|
put ' %if &i>1 %then "," ; ';
|
|
233
251
|
put ' %if &action=OBJ %then """&&name&i"":" ; ';
|
|
234
252
|
put ' &&name&i ';
|
|
235
253
|
put ' %end; ';
|
|
236
254
|
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
|
237
|
-
put ' proc sql; ';
|
|
238
|
-
put ' drop view &tempds; ';
|
|
239
255
|
put ' /* now write the long strings to _webout 1 byte at a time */ ';
|
|
240
256
|
put ' data _null_; ';
|
|
241
257
|
put ' length filein 8 fileid 8; ';
|
|
242
|
-
put ' filein
|
|
243
|
-
put ' fileid
|
|
244
|
-
put ' rec
|
|
258
|
+
put ' filein=fopen("_sjs",''I'',1,''B''); ';
|
|
259
|
+
put ' fileid=fopen("&jref",''A'',1,''B''); ';
|
|
260
|
+
put ' rec=''20''x; ';
|
|
245
261
|
put ' do while(fread(filein)=0); ';
|
|
246
|
-
put ' rc
|
|
247
|
-
put ' rc
|
|
248
|
-
put ' rc
|
|
262
|
+
put ' rc=fget(filein,rec,1); ';
|
|
263
|
+
put ' rc=fput(fileid, rec); ';
|
|
264
|
+
put ' rc=fwrite(fileid); ';
|
|
249
265
|
put ' end; ';
|
|
250
|
-
put '
|
|
251
|
-
put ' rc
|
|
266
|
+
put ' /* close out the table */ ';
|
|
267
|
+
put ' rc=fput(fileid, "]"); ';
|
|
268
|
+
put ' rc=fwrite(fileid); ';
|
|
269
|
+
put ' rc=fclose(filein); ';
|
|
270
|
+
put ' rc=fclose(fileid); ';
|
|
252
271
|
put ' run; ';
|
|
253
272
|
put ' filename _sjs clear; ';
|
|
254
|
-
put '
|
|
255
|
-
put '
|
|
273
|
+
put ' %end; ';
|
|
274
|
+
put ' ';
|
|
275
|
+
put ' proc sql; ';
|
|
276
|
+
put ' drop view &tempds; ';
|
|
277
|
+
put ' drop table &colinfo; ';
|
|
278
|
+
put ' ';
|
|
279
|
+
put ' %if &showmeta=YES %then %do; ';
|
|
280
|
+
put ' data _null_; file &jref encoding=''utf-8'' mod; ';
|
|
281
|
+
put ' put ", ""$%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":{""vars"":{"; ';
|
|
282
|
+
put ' do i=1 to &numcols; ';
|
|
283
|
+
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
|
284
|
+
put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
|
|
285
|
+
put ' label=quote(trim(symget(cats(''label'',i)))); ';
|
|
286
|
+
put ' length=quote(trim(symget(cats(''length'',i)))); ';
|
|
287
|
+
put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
|
|
288
|
+
put ' if i>1 then put "," @@; ';
|
|
289
|
+
put ' put name '':{"format":'' format '',"label":'' label ';
|
|
290
|
+
put ' '',"length":'' length '',"type":'' type ''}''; ';
|
|
291
|
+
put ' end; ';
|
|
292
|
+
put ' put ''}}''; ';
|
|
256
293
|
put ' run; ';
|
|
257
294
|
put ' %end; ';
|
|
258
295
|
put '%end; ';
|
|
259
296
|
put ' ';
|
|
260
297
|
put '%else %if &action=CLOSE %then %do; ';
|
|
261
|
-
put ' data _null_;file &jref encoding=''utf-8'' mod ; ';
|
|
298
|
+
put ' data _null_; file &jref encoding=''utf-8'' mod ; ';
|
|
262
299
|
put ' put "}"; ';
|
|
263
300
|
put ' run; ';
|
|
264
301
|
put '%end; ';
|
|
265
302
|
put '%mend mp_jsonout; ';
|
|
266
|
-
put '%macro mm_webout(action,ds,dslabel=,fref=_webout,fmt=Y
|
|
303
|
+
put '%macro mm_webout(action,ds,dslabel=,fref=_webout,fmt=Y,missing=NULL ';
|
|
304
|
+
put ' ,showmeta=NO ';
|
|
305
|
+
put '); ';
|
|
267
306
|
put '%global _webin_file_count _webin_fileref1 _webin_name1 _program _debug ';
|
|
268
307
|
put ' sasjs_tables; ';
|
|
269
308
|
put '%local i tempds jsonengine; ';
|
|
@@ -321,14 +360,15 @@ data _null_;
|
|
|
321
360
|
put ' %if %str(&_debug) ge 131 %then %do; ';
|
|
322
361
|
put ' put ''>>weboutBEGIN<<''; ';
|
|
323
362
|
put ' %end; ';
|
|
324
|
-
put ' put ''{"
|
|
363
|
+
put ' put ''{"SYSDATE" : "'' "&SYSDATE" ''"''; ';
|
|
364
|
+
put ' put '',"SYSTIME" : "'' "&SYSTIME" ''"''; ';
|
|
325
365
|
put ' run; ';
|
|
326
366
|
put ' ';
|
|
327
367
|
put '%end; ';
|
|
328
368
|
put ' ';
|
|
329
369
|
put '%else %if &action=ARR or &action=OBJ %then %do; ';
|
|
330
370
|
put ' %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt,jref=&fref ';
|
|
331
|
-
put ' ,engine=&jsonengine,
|
|
371
|
+
put ' ,engine=&jsonengine,missing=&missing,showmeta=&showmeta ';
|
|
332
372
|
put ' ) ';
|
|
333
373
|
put '%end; ';
|
|
334
374
|
put '%else %if &action=CLOSE %then %do; ';
|
|
@@ -349,9 +389,6 @@ data _null_;
|
|
|
349
389
|
put ' put ",""WORK"":{"; ';
|
|
350
390
|
put ' %do i=1 %to &wtcnt; ';
|
|
351
391
|
put ' %let wt=&&wt&i; ';
|
|
352
|
-
put ' proc contents noprint data=&wt ';
|
|
353
|
-
put ' out=_data_ (keep=name type length format:); ';
|
|
354
|
-
put ' run;%let tempds=%scan(&syslast,2,.); ';
|
|
355
392
|
put ' data _null_; file &fref mod encoding=''utf-8''; ';
|
|
356
393
|
put ' dsid=open("WORK.&wt",''is''); ';
|
|
357
394
|
put ' nlobs=attrn(dsid,''NLOBS''); ';
|
|
@@ -361,8 +398,7 @@ data _null_;
|
|
|
361
398
|
put ' put " ""&wt"" : {"; ';
|
|
362
399
|
put ' put ''"nlobs":'' nlobs; ';
|
|
363
400
|
put ' put '',"nvars":'' nvars; ';
|
|
364
|
-
put ' %mp_jsonout(OBJ,&
|
|
365
|
-
put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,engine=&jsonengine) ';
|
|
401
|
+
put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=YES) ';
|
|
366
402
|
put ' data _null_; file &fref mod encoding=''utf-8''; ';
|
|
367
403
|
put ' put "}"; ';
|
|
368
404
|
put ' %end; ';
|
|
@@ -391,6 +427,9 @@ data _null_;
|
|
|
391
427
|
put ' put '',"SYSVLONG" : '' sysvlong; ';
|
|
392
428
|
put ' put ",""SYSWARNINGTEXT"" : ""&syswarningtext"" "; ';
|
|
393
429
|
put ' put '',"END_DTTM" : "'' "%sysfunc(datetime(),datetime20.3)" ''" ''; ';
|
|
430
|
+
put ' memsize="%sysfunc(INPUTN(%sysfunc(getoption(memsize)), best.),sizekmg.)"; ';
|
|
431
|
+
put ' memsize=quote(cats(memsize)); ';
|
|
432
|
+
put ' put '',"MEMSIZE" : '' memsize; ';
|
|
394
433
|
put ' put "}" @; ';
|
|
395
434
|
put ' %if %str(&_debug) ge 131 %then %do; ';
|
|
396
435
|
put ' put ''>>weboutEND<<''; ';
|
|
@@ -418,8 +457,10 @@ data _null_;
|
|
|
418
457
|
put ' ';
|
|
419
458
|
put '%mend mf_getuser; ';
|
|
420
459
|
/* WEBOUT END */
|
|
421
|
-
put '%macro webout(action,ds,dslabel=,fmt=);';
|
|
422
|
-
put ' %mm_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt
|
|
460
|
+
put '%macro webout(action,ds,dslabel=,fmt=,missing=NULL,showmeta=NO);';
|
|
461
|
+
put ' %mm_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt,missing=&missing';
|
|
462
|
+
put ' ,showmeta=&showmeta';
|
|
463
|
+
put ' )';
|
|
423
464
|
put '%mend;';
|
|
424
465
|
run;
|
|
425
466
|
|
package/meta/mm_webout.sas
CHANGED
|
@@ -23,17 +23,25 @@
|
|
|
23
23
|
%mm_webout(CLOSE)
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
@param action Either FETCH, OPEN, ARR, OBJ or CLOSE
|
|
27
|
-
@param ds The dataset to send back to the frontend
|
|
28
|
-
@param dslabel=
|
|
29
|
-
@param fmt=(Y) Set to N to send back unformatted values
|
|
30
|
-
@param fref=(_webout) The fileref to which to write the JSON
|
|
26
|
+
@param [in] action Either FETCH, OPEN, ARR, OBJ or CLOSE
|
|
27
|
+
@param [in] ds The dataset to send back to the frontend
|
|
28
|
+
@param [out] dslabel= Value to use instead of table name for sending to JSON
|
|
29
|
+
@param [in] fmt=(Y) Set to N to send back unformatted values
|
|
30
|
+
@param [out] fref= (_webout) The fileref to which to write the JSON
|
|
31
|
+
@param [in] missing= (NULL) Special numeric missing values can be sent as NULL
|
|
32
|
+
(eg `null`) or as STRING values (eg `".a"` or `".b"`)
|
|
33
|
+
@param [in] showmeta= (NO) Set to YES to output metadata alongside each table,
|
|
34
|
+
such as the column formats and types. The metadata is contained inside an
|
|
35
|
+
object with the same name as the table but prefixed with a dollar sign - ie,
|
|
36
|
+
`,"$tablename":{"formats":{"col1":"$CHAR1"},"types":{"COL1":"C"}}`
|
|
31
37
|
|
|
32
38
|
@version 9.3
|
|
33
39
|
@author Allan Bowe
|
|
34
40
|
|
|
35
41
|
**/
|
|
36
|
-
%macro mm_webout(action,ds,dslabel=,fref=_webout,fmt=Y
|
|
42
|
+
%macro mm_webout(action,ds,dslabel=,fref=_webout,fmt=Y,missing=NULL
|
|
43
|
+
,showmeta=NO
|
|
44
|
+
);
|
|
37
45
|
%global _webin_file_count _webin_fileref1 _webin_name1 _program _debug
|
|
38
46
|
sasjs_tables;
|
|
39
47
|
%local i tempds jsonengine;
|
|
@@ -91,14 +99,15 @@
|
|
|
91
99
|
%if %str(&_debug) ge 131 %then %do;
|
|
92
100
|
put '>>weboutBEGIN<<';
|
|
93
101
|
%end;
|
|
94
|
-
put '{"
|
|
102
|
+
put '{"SYSDATE" : "' "&SYSDATE" '"';
|
|
103
|
+
put ',"SYSTIME" : "' "&SYSTIME" '"';
|
|
95
104
|
run;
|
|
96
105
|
|
|
97
106
|
%end;
|
|
98
107
|
|
|
99
108
|
%else %if &action=ARR or &action=OBJ %then %do;
|
|
100
109
|
%mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt,jref=&fref
|
|
101
|
-
,engine=&jsonengine,
|
|
110
|
+
,engine=&jsonengine,missing=&missing,showmeta=&showmeta
|
|
102
111
|
)
|
|
103
112
|
%end;
|
|
104
113
|
%else %if &action=CLOSE %then %do;
|
|
@@ -119,9 +128,6 @@
|
|
|
119
128
|
put ",""WORK"":{";
|
|
120
129
|
%do i=1 %to &wtcnt;
|
|
121
130
|
%let wt=&&wt&i;
|
|
122
|
-
proc contents noprint data=&wt
|
|
123
|
-
out=_data_ (keep=name type length format:);
|
|
124
|
-
run;%let tempds=%scan(&syslast,2,.);
|
|
125
131
|
data _null_; file &fref mod encoding='utf-8';
|
|
126
132
|
dsid=open("WORK.&wt",'is');
|
|
127
133
|
nlobs=attrn(dsid,'NLOBS');
|
|
@@ -131,8 +137,7 @@
|
|
|
131
137
|
put " ""&wt"" : {";
|
|
132
138
|
put '"nlobs":' nlobs;
|
|
133
139
|
put ',"nvars":' nvars;
|
|
134
|
-
%mp_jsonout(OBJ,&
|
|
135
|
-
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,engine=&jsonengine)
|
|
140
|
+
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=YES)
|
|
136
141
|
data _null_; file &fref mod encoding='utf-8';
|
|
137
142
|
put "}";
|
|
138
143
|
%end;
|
|
@@ -161,6 +166,9 @@
|
|
|
161
166
|
put ',"SYSVLONG" : ' sysvlong;
|
|
162
167
|
put ",""SYSWARNINGTEXT"" : ""&syswarningtext"" ";
|
|
163
168
|
put ',"END_DTTM" : "' "%sysfunc(datetime(),datetime20.3)" '" ';
|
|
169
|
+
memsize="%sysfunc(INPUTN(%sysfunc(getoption(memsize)), best.),sizekmg.)";
|
|
170
|
+
memsize=quote(cats(memsize));
|
|
171
|
+
put ',"MEMSIZE" : ' memsize;
|
|
164
172
|
put "}" @;
|
|
165
173
|
%if %str(&_debug) ge 131 %then %do;
|
|
166
174
|
put '>>weboutEND<<';
|
package/package.json
CHANGED
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"prepare": "git rev-parse --git-dir && git config core.hooksPath ./.git-hooks || true"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@sasjs/cli": "^
|
|
36
|
+
"@sasjs/cli": "^3.4.1"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"ts-loader": "^9.2.6"
|
|
40
40
|
},
|
|
41
|
-
"version": "3.
|
|
41
|
+
"version": "3.9.1"
|
|
42
42
|
}
|
package/server/ms_webout.sas
CHANGED
|
@@ -20,11 +20,17 @@
|
|
|
20
20
|
%ms_webout(CLOSE)
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
@param action Either FETCH, OPEN, ARR, OBJ or CLOSE
|
|
24
|
-
@param ds The dataset to send back to the frontend
|
|
25
|
-
@param dslabel= value to use instead of
|
|
26
|
-
@param fmt=(Y) Set to N to send back unformatted values
|
|
27
|
-
@param fref=(_webout) The fileref to which to write the JSON
|
|
23
|
+
@param [in] action Either FETCH, OPEN, ARR, OBJ or CLOSE
|
|
24
|
+
@param [in] ds The dataset to send back to the frontend
|
|
25
|
+
@param [out] dslabel= value to use instead of table name for sending to JSON
|
|
26
|
+
@param [in] fmt= (Y) Set to N to send back unformatted values
|
|
27
|
+
@param [out] fref= (_webout) The fileref to which to write the JSON
|
|
28
|
+
@param [in] missing= (NULL) Special numeric missing values can be sent as NULL
|
|
29
|
+
(eg `null`) or as STRING values (eg `".a"` or `".b"`)
|
|
30
|
+
@param [in] showmeta= (NO) Set to YES to output metadata alongside each table,
|
|
31
|
+
such as the column formats and types. The metadata is contained inside an
|
|
32
|
+
object with the same name as the table but prefixed with a dollar sign - ie,
|
|
33
|
+
`,"$tablename":{"formats":{"col1":"$CHAR1"},"types":{"COL1":"C"}}`
|
|
28
34
|
|
|
29
35
|
<h4> SAS Macros </h4>
|
|
30
36
|
@li mp_jsonout.sas
|
|
@@ -39,7 +45,9 @@
|
|
|
39
45
|
|
|
40
46
|
**/
|
|
41
47
|
|
|
42
|
-
%macro ms_webout(action,ds,dslabel=,fref=_webout,fmt=Y
|
|
48
|
+
%macro ms_webout(action,ds,dslabel=,fref=_webout,fmt=Y,missing=NULL
|
|
49
|
+
,showmeta=NO
|
|
50
|
+
);
|
|
43
51
|
%global _webin_file_count _webin_fileref1 _webin_name1 _program _debug
|
|
44
52
|
sasjs_tables;
|
|
45
53
|
|
|
@@ -91,7 +99,7 @@
|
|
|
91
99
|
|
|
92
100
|
%else %if &action=ARR or &action=OBJ %then %do;
|
|
93
101
|
%mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt,jref=&fref
|
|
94
|
-
,engine=DATASTEP,
|
|
102
|
+
,engine=DATASTEP,missing=&missing,showmeta=&showmeta
|
|
95
103
|
)
|
|
96
104
|
%end;
|
|
97
105
|
%else %if &action=CLOSE %then %do;
|
|
@@ -112,9 +120,6 @@
|
|
|
112
120
|
put ",""WORK"":{";
|
|
113
121
|
%do i=1 %to &wtcnt;
|
|
114
122
|
%let wt=&&wt&i;
|
|
115
|
-
proc contents noprint data=&wt
|
|
116
|
-
out=_data_ (keep=name type length format:);
|
|
117
|
-
run;%let tempds=%scan(&syslast,2,.);
|
|
118
123
|
data _null_; file &fref mod encoding='utf-8' termstr=lf;
|
|
119
124
|
dsid=open("WORK.&wt",'is');
|
|
120
125
|
nlobs=attrn(dsid,'NLOBS');
|
|
@@ -124,8 +129,7 @@
|
|
|
124
129
|
put " ""&wt"" : {";
|
|
125
130
|
put '"nlobs":' nlobs;
|
|
126
131
|
put ',"nvars":' nvars;
|
|
127
|
-
%mp_jsonout(OBJ,&
|
|
128
|
-
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,engine=DATASTEP)
|
|
132
|
+
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=YES)
|
|
129
133
|
data _null_; file &fref mod encoding='utf-8' termstr=lf;
|
|
130
134
|
put "}";
|
|
131
135
|
%end;
|