@sasjs/core 3.8.0 → 3.9.2
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/base/mp_dirlist.sas +25 -9
- package/base/mp_jsonout.sas +114 -93
- package/base/mp_lockanytable.sas +1 -1
- package/meta/mm_createstp.sas +11 -8
- package/meta/mm_createwebservice.sas +137 -112
- package/meta/mm_webout.sas +14 -8
- package/package.json +2 -2
- package/server/ms_webout.sas +9 -7
- package/viya/mv_createwebservice.sas +126 -105
- package/viya/mv_webout.sas +14 -8
|
@@ -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,10 +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 */ ';
|
|
93
99
|
put ' ,missing=NULL ';
|
|
100
|
+
put ' ,showmeta=NO ';
|
|
94
101
|
put ')/*/STORE SOURCE*/; ';
|
|
95
|
-
put '%
|
|
102
|
+
put '%local tempds colinfo fmtds i numcols; ';
|
|
103
|
+
put '%let numcols=0; ';
|
|
104
|
+
put ' ';
|
|
96
105
|
put '%if &action=OPEN %then %do; ';
|
|
97
106
|
put ' options nobomfile; ';
|
|
98
107
|
put ' data _null_;file &jref encoding=''utf-8'' ; ';
|
|
@@ -101,17 +110,61 @@ data _null_;
|
|
|
101
110
|
put '%end; ';
|
|
102
111
|
put '%else %if (&action=ARR or &action=OBJ) %then %do; ';
|
|
103
112
|
put ' options validvarname=upcase; ';
|
|
104
|
-
put ' data _null_;file &jref
|
|
113
|
+
put ' data _null_; file &jref encoding=''utf-8'' mod; ';
|
|
105
114
|
put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
|
|
106
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 ' ';
|
|
107
162
|
put ' %if &engine=PROCJSON %then %do; ';
|
|
108
163
|
put ' %if &missing=STRING %then %do; ';
|
|
109
|
-
put ' %put &sysmacroname: Special Missings
|
|
164
|
+
put ' %put &sysmacroname: Special Missings not supported in proc json.; ';
|
|
110
165
|
put ' %put &sysmacroname: Switching to DATASTEP engine; ';
|
|
111
166
|
put ' %goto datastep; ';
|
|
112
167
|
put ' %end; ';
|
|
113
|
-
put ' data;run;%let tempds=&syslast; ';
|
|
114
|
-
put ' proc sql;drop table &tempds; ';
|
|
115
168
|
put ' data &tempds /view=&tempds;set &ds; ';
|
|
116
169
|
put ' %if &fmt=N %then format _numeric_ best32.;; ';
|
|
117
170
|
put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
|
|
@@ -119,91 +172,35 @@ data _null_;
|
|
|
119
172
|
put ' %if &action=ARR %then nokeys ; ';
|
|
120
173
|
put ' ;export &tempds / nosastags fmtnumeric; ';
|
|
121
174
|
put ' run; ';
|
|
122
|
-
put ' proc sql;drop view &tempds; ';
|
|
123
175
|
put ' %end; ';
|
|
124
176
|
put ' %else %if &engine=DATASTEP %then %do; ';
|
|
125
177
|
put ' %datastep: ';
|
|
126
|
-
put ' %
|
|
127
|
-
put ' %
|
|
128
|
-
put ' %if %sysfunc(exist(&ds)) ne 1 & %sysfunc(exist(&ds,VIEW)) ne 1 %then %do; ';
|
|
178
|
+
put ' %if %sysfunc(exist(&ds)) ne 1 & %sysfunc(exist(&ds,VIEW)) ne 1 ';
|
|
179
|
+
put ' %then %do; ';
|
|
129
180
|
put ' %put &sysmacroname: &ds NOT FOUND!!!; ';
|
|
130
181
|
put ' %return; ';
|
|
131
182
|
put ' %end; ';
|
|
132
|
-
put ' %if &fmt=Y %then %do; ';
|
|
133
|
-
put ' %put converting every variable to a formatted variable; ';
|
|
134
|
-
put ' /* see mp_ds2fmtds.sas for source */ ';
|
|
135
|
-
put ' proc contents noprint data=&ds ';
|
|
136
|
-
put ' out=_data_(keep=name type length format formatl formatd varnum); ';
|
|
137
|
-
put ' run; ';
|
|
138
|
-
put ' proc sort; ';
|
|
139
|
-
put ' by varnum; ';
|
|
140
|
-
put ' run; ';
|
|
141
|
-
put ' %local fmtds; ';
|
|
142
|
-
put ' %let fmtds=%scan(&syslast,2,.); ';
|
|
143
|
-
put ' /* prepare formats and varnames */ ';
|
|
144
|
-
put ' data _null_; ';
|
|
145
|
-
put ' if _n_=1 then call symputx(''nobs'',nobs,''l''); ';
|
|
146
|
-
put ' set &fmtds end=last nobs=nobs; ';
|
|
147
|
-
put ' name=upcase(name); ';
|
|
148
|
-
put ' /* fix formats */ ';
|
|
149
|
-
put ' if type=2 or type=6 then do; ';
|
|
150
|
-
put ' length fmt $49.; ';
|
|
151
|
-
put ' if format='''' then fmt=cats(''$'',length,''.''); ';
|
|
152
|
-
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
|
153
|
-
put ' else fmt=cats(format,formatl,''.''); ';
|
|
154
|
-
put ' newlen=max(formatl,length); ';
|
|
155
|
-
put ' end; ';
|
|
156
|
-
put ' else do; ';
|
|
157
|
-
put ' if format='''' then fmt=''best.''; ';
|
|
158
|
-
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
|
159
|
-
put ' else if formatd=0 then fmt=cats(format,formatl,''.''); ';
|
|
160
|
-
put ' else fmt=cats(format,formatl,''.'',formatd); ';
|
|
161
|
-
put ' /* needs to be wide, for datetimes etc */ ';
|
|
162
|
-
put ' newlen=max(length,formatl,24); ';
|
|
163
|
-
put ' end; ';
|
|
164
|
-
put ' /* 32 char unique name */ ';
|
|
165
|
-
put ' newname=''sasjs''!!substr(cats(put(md5(name),$hex32.)),1,27); ';
|
|
166
183
|
put ' ';
|
|
167
|
-
put '
|
|
168
|
-
put '
|
|
169
|
-
put ' call symputx(cats(''len'',_n_),newlen,''l''); ';
|
|
170
|
-
put ' call symputx(cats(''fmt'',_n_),fmt,''l''); ';
|
|
171
|
-
put ' call symputx(cats(''type'',_n_),type,''l''); ';
|
|
172
|
-
put ' run; ';
|
|
173
|
-
put ' data &fmtds; ';
|
|
184
|
+
put ' %if &fmt=Y %then %do; ';
|
|
185
|
+
put ' data _data_; ';
|
|
174
186
|
put ' /* rename on entry */ ';
|
|
175
187
|
put ' set &ds(rename=( ';
|
|
176
|
-
put ' %
|
|
177
|
-
put ' %do i=1 %to &nobs; ';
|
|
188
|
+
put ' %do i=1 %to &numcols; ';
|
|
178
189
|
put ' &&name&i=&&newname&i ';
|
|
179
190
|
put ' %end; ';
|
|
180
191
|
put ' )); ';
|
|
181
|
-
put ' %do i=1 %to &
|
|
192
|
+
put ' %do i=1 %to &numcols; ';
|
|
182
193
|
put ' length &&name&i $&&len&i; ';
|
|
183
194
|
put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
|
|
184
195
|
put ' drop &&newname&i; ';
|
|
185
196
|
put ' %end; ';
|
|
186
197
|
put ' if _error_ then call symputx(''syscc'',1012); ';
|
|
187
198
|
put ' run; ';
|
|
188
|
-
put ' %let
|
|
189
|
-
put ' %end;
|
|
190
|
-
put ' data _null_;file &jref mod encoding=''utf-8'' ; ';
|
|
191
|
-
put ' put "["; call symputx(''cols'',0,''l''); ';
|
|
192
|
-
put ' proc sort ';
|
|
193
|
-
put ' data=sashelp.vcolumn(where=(libname=''WORK'' & memname="%upcase(&ds)")) ';
|
|
194
|
-
put ' out=_data_; ';
|
|
195
|
-
put ' by varnum; ';
|
|
196
|
-
put ' ';
|
|
197
|
-
put ' data _null_; ';
|
|
198
|
-
put ' set _last_ end=last; ';
|
|
199
|
-
put ' call symputx(cats(''name'',_n_),name,''l''); ';
|
|
200
|
-
put ' call symputx(cats(''type'',_n_),type,''l''); ';
|
|
201
|
-
put ' call symputx(cats(''len'',_n_),length,''l''); ';
|
|
202
|
-
put ' if last then call symputx(''cols'',_n_,''l''); ';
|
|
203
|
-
put ' run; ';
|
|
199
|
+
put ' %let fmtds=&syslast; ';
|
|
200
|
+
put ' %end; ';
|
|
204
201
|
put ' ';
|
|
205
202
|
put ' proc format; /* credit yabwon for special null removal */ ';
|
|
206
|
-
put ' value bart ';
|
|
203
|
+
put ' value bart (default=40) ';
|
|
207
204
|
put ' %if &missing=NULL %then %do; ';
|
|
208
205
|
put ' ._ - .z = null ';
|
|
209
206
|
put ' %end; ';
|
|
@@ -214,20 +211,23 @@ data _null_;
|
|
|
214
211
|
put ' %end; ';
|
|
215
212
|
put ' other = [best.]; ';
|
|
216
213
|
put ' ';
|
|
217
|
-
put ' data;run; %let tempds=&syslast; /* temp table for spesh char management */ ';
|
|
218
|
-
put ' proc sql; drop table &tempds; ';
|
|
219
214
|
put ' data &tempds/view=&tempds; ';
|
|
220
215
|
put ' attrib _all_ label=''''; ';
|
|
221
|
-
put ' %do i=1 %to &
|
|
222
|
-
put ' %if &&
|
|
216
|
+
put ' %do i=1 %to &numcols; ';
|
|
217
|
+
put ' %if &&typelong&i=char or &fmt=Y %then %do; ';
|
|
223
218
|
put ' length &&name&i $32767; ';
|
|
224
219
|
put ' format &&name&i $32767.; ';
|
|
225
220
|
put ' %end; ';
|
|
226
221
|
put ' %end; ';
|
|
227
|
-
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; ';
|
|
228
228
|
put ' format _numeric_ bart.; ';
|
|
229
|
-
put ' %do i=1 %to &
|
|
230
|
-
put ' %if &&
|
|
229
|
+
put ' %do i=1 %to &numcols; ';
|
|
230
|
+
put ' %if &&typelong&i=char or &fmt=Y %then %do; ';
|
|
231
231
|
put ' &&name&i=''"''!!trim(prxchange(''s/"/\"/'',-1, ';
|
|
232
232
|
put ' prxchange(''s/''!!''0A''x!!''/\n/'',-1, ';
|
|
233
233
|
put ' prxchange(''s/''!!''0D''x!!''/\r/'',-1, ';
|
|
@@ -237,49 +237,72 @@ data _null_;
|
|
|
237
237
|
put ' %end; ';
|
|
238
238
|
put ' %end; ';
|
|
239
239
|
put ' run; ';
|
|
240
|
+
put ' ';
|
|
240
241
|
put ' /* write to temp loc to avoid _webout truncation ';
|
|
241
242
|
put ' - https://support.sas.com/kb/49/325.html */ ';
|
|
242
243
|
put ' filename _sjs temp lrecl=131068 encoding=''utf-8''; ';
|
|
243
244
|
put ' data _null_; file _sjs lrecl=131068 encoding=''utf-8'' mod ; ';
|
|
245
|
+
put ' if _n_=1 then put "["; ';
|
|
244
246
|
put ' set &tempds; ';
|
|
245
247
|
put ' if _n_>1 then put "," @; put ';
|
|
246
248
|
put ' %if &action=ARR %then "[" ; %else "{" ; ';
|
|
247
|
-
put ' %do i=1 %to &
|
|
249
|
+
put ' %do i=1 %to &numcols; ';
|
|
248
250
|
put ' %if &i>1 %then "," ; ';
|
|
249
251
|
put ' %if &action=OBJ %then """&&name&i"":" ; ';
|
|
250
252
|
put ' &&name&i ';
|
|
251
253
|
put ' %end; ';
|
|
252
254
|
put ' %if &action=ARR %then "]" ; %else "}" ; ; ';
|
|
253
|
-
put ' proc sql; ';
|
|
254
|
-
put ' drop view &tempds; ';
|
|
255
255
|
put ' /* now write the long strings to _webout 1 byte at a time */ ';
|
|
256
256
|
put ' data _null_; ';
|
|
257
257
|
put ' length filein 8 fileid 8; ';
|
|
258
|
-
put ' filein
|
|
259
|
-
put ' fileid
|
|
260
|
-
put ' rec
|
|
258
|
+
put ' filein=fopen("_sjs",''I'',1,''B''); ';
|
|
259
|
+
put ' fileid=fopen("&jref",''A'',1,''B''); ';
|
|
260
|
+
put ' rec=''20''x; ';
|
|
261
261
|
put ' do while(fread(filein)=0); ';
|
|
262
|
-
put ' rc
|
|
263
|
-
put ' rc
|
|
264
|
-
put ' rc
|
|
262
|
+
put ' rc=fget(filein,rec,1); ';
|
|
263
|
+
put ' rc=fput(fileid, rec); ';
|
|
264
|
+
put ' rc=fwrite(fileid); ';
|
|
265
265
|
put ' end; ';
|
|
266
|
-
put '
|
|
267
|
-
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); ';
|
|
268
271
|
put ' run; ';
|
|
269
272
|
put ' filename _sjs clear; ';
|
|
270
|
-
put '
|
|
271
|
-
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 ''}}''; ';
|
|
272
293
|
put ' run; ';
|
|
273
294
|
put ' %end; ';
|
|
274
295
|
put '%end; ';
|
|
275
296
|
put ' ';
|
|
276
297
|
put '%else %if &action=CLOSE %then %do; ';
|
|
277
|
-
put ' data _null_;file &jref encoding=''utf-8'' mod ; ';
|
|
298
|
+
put ' data _null_; file &jref encoding=''utf-8'' mod ; ';
|
|
278
299
|
put ' put "}"; ';
|
|
279
300
|
put ' run; ';
|
|
280
301
|
put '%end; ';
|
|
281
302
|
put '%mend mp_jsonout; ';
|
|
282
|
-
put '%macro mm_webout(action,ds,dslabel=,fref=_webout,fmt=Y,missing=NULL
|
|
303
|
+
put '%macro mm_webout(action,ds,dslabel=,fref=_webout,fmt=Y,missing=NULL ';
|
|
304
|
+
put ' ,showmeta=NO ';
|
|
305
|
+
put '); ';
|
|
283
306
|
put '%global _webin_file_count _webin_fileref1 _webin_name1 _program _debug ';
|
|
284
307
|
put ' sasjs_tables; ';
|
|
285
308
|
put '%local i tempds jsonengine; ';
|
|
@@ -337,14 +360,15 @@ data _null_;
|
|
|
337
360
|
put ' %if %str(&_debug) ge 131 %then %do; ';
|
|
338
361
|
put ' put ''>>weboutBEGIN<<''; ';
|
|
339
362
|
put ' %end; ';
|
|
340
|
-
put ' put ''{"
|
|
363
|
+
put ' put ''{"SYSDATE" : "'' "&SYSDATE" ''"''; ';
|
|
364
|
+
put ' put '',"SYSTIME" : "'' "&SYSTIME" ''"''; ';
|
|
341
365
|
put ' run; ';
|
|
342
366
|
put ' ';
|
|
343
367
|
put '%end; ';
|
|
344
368
|
put ' ';
|
|
345
369
|
put '%else %if &action=ARR or &action=OBJ %then %do; ';
|
|
346
370
|
put ' %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt,jref=&fref ';
|
|
347
|
-
put ' ,engine=&jsonengine,missing=&missing ';
|
|
371
|
+
put ' ,engine=&jsonengine,missing=&missing,showmeta=&showmeta ';
|
|
348
372
|
put ' ) ';
|
|
349
373
|
put '%end; ';
|
|
350
374
|
put '%else %if &action=CLOSE %then %do; ';
|
|
@@ -365,9 +389,6 @@ data _null_;
|
|
|
365
389
|
put ' put ",""WORK"":{"; ';
|
|
366
390
|
put ' %do i=1 %to &wtcnt; ';
|
|
367
391
|
put ' %let wt=&&wt&i; ';
|
|
368
|
-
put ' proc contents noprint data=&wt ';
|
|
369
|
-
put ' out=_data_ (keep=name type length format:); ';
|
|
370
|
-
put ' run;%let tempds=%scan(&syslast,2,.); ';
|
|
371
392
|
put ' data _null_; file &fref mod encoding=''utf-8''; ';
|
|
372
393
|
put ' dsid=open("WORK.&wt",''is''); ';
|
|
373
394
|
put ' nlobs=attrn(dsid,''NLOBS''); ';
|
|
@@ -377,8 +398,7 @@ data _null_;
|
|
|
377
398
|
put ' put " ""&wt"" : {"; ';
|
|
378
399
|
put ' put ''"nlobs":'' nlobs; ';
|
|
379
400
|
put ' put '',"nvars":'' nvars; ';
|
|
380
|
-
put ' %mp_jsonout(OBJ,&
|
|
381
|
-
put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,engine=&jsonengine) ';
|
|
401
|
+
put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=YES) ';
|
|
382
402
|
put ' data _null_; file &fref mod encoding=''utf-8''; ';
|
|
383
403
|
put ' put "}"; ';
|
|
384
404
|
put ' %end; ';
|
|
@@ -407,6 +427,9 @@ data _null_;
|
|
|
407
427
|
put ' put '',"SYSVLONG" : '' sysvlong; ';
|
|
408
428
|
put ' put ",""SYSWARNINGTEXT"" : ""&syswarningtext"" "; ';
|
|
409
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; ';
|
|
410
433
|
put ' put "}" @; ';
|
|
411
434
|
put ' %if %str(&_debug) ge 131 %then %do; ';
|
|
412
435
|
put ' put ''>>weboutEND<<''; ';
|
|
@@ -434,8 +457,10 @@ data _null_;
|
|
|
434
457
|
put ' ';
|
|
435
458
|
put '%mend mf_getuser; ';
|
|
436
459
|
/* WEBOUT END */
|
|
437
|
-
put '%macro webout(action,ds,dslabel=,fmt=);';
|
|
438
|
-
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 ' )';
|
|
439
464
|
put '%mend;';
|
|
440
465
|
run;
|
|
441
466
|
|
package/meta/mm_webout.sas
CHANGED
|
@@ -30,12 +30,18 @@
|
|
|
30
30
|
@param [out] fref= (_webout) The fileref to which to write the JSON
|
|
31
31
|
@param [in] missing= (NULL) Special numeric missing values can be sent as NULL
|
|
32
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"}}`
|
|
33
37
|
|
|
34
38
|
@version 9.3
|
|
35
39
|
@author Allan Bowe
|
|
36
40
|
|
|
37
41
|
**/
|
|
38
|
-
%macro mm_webout(action,ds,dslabel=,fref=_webout,fmt=Y,missing=NULL
|
|
42
|
+
%macro mm_webout(action,ds,dslabel=,fref=_webout,fmt=Y,missing=NULL
|
|
43
|
+
,showmeta=NO
|
|
44
|
+
);
|
|
39
45
|
%global _webin_file_count _webin_fileref1 _webin_name1 _program _debug
|
|
40
46
|
sasjs_tables;
|
|
41
47
|
%local i tempds jsonengine;
|
|
@@ -93,14 +99,15 @@
|
|
|
93
99
|
%if %str(&_debug) ge 131 %then %do;
|
|
94
100
|
put '>>weboutBEGIN<<';
|
|
95
101
|
%end;
|
|
96
|
-
put '{"
|
|
102
|
+
put '{"SYSDATE" : "' "&SYSDATE" '"';
|
|
103
|
+
put ',"SYSTIME" : "' "&SYSTIME" '"';
|
|
97
104
|
run;
|
|
98
105
|
|
|
99
106
|
%end;
|
|
100
107
|
|
|
101
108
|
%else %if &action=ARR or &action=OBJ %then %do;
|
|
102
109
|
%mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt,jref=&fref
|
|
103
|
-
,engine=&jsonengine,missing=&missing
|
|
110
|
+
,engine=&jsonengine,missing=&missing,showmeta=&showmeta
|
|
104
111
|
)
|
|
105
112
|
%end;
|
|
106
113
|
%else %if &action=CLOSE %then %do;
|
|
@@ -121,9 +128,6 @@
|
|
|
121
128
|
put ",""WORK"":{";
|
|
122
129
|
%do i=1 %to &wtcnt;
|
|
123
130
|
%let wt=&&wt&i;
|
|
124
|
-
proc contents noprint data=&wt
|
|
125
|
-
out=_data_ (keep=name type length format:);
|
|
126
|
-
run;%let tempds=%scan(&syslast,2,.);
|
|
127
131
|
data _null_; file &fref mod encoding='utf-8';
|
|
128
132
|
dsid=open("WORK.&wt",'is');
|
|
129
133
|
nlobs=attrn(dsid,'NLOBS');
|
|
@@ -133,8 +137,7 @@
|
|
|
133
137
|
put " ""&wt"" : {";
|
|
134
138
|
put '"nlobs":' nlobs;
|
|
135
139
|
put ',"nvars":' nvars;
|
|
136
|
-
%mp_jsonout(OBJ,&
|
|
137
|
-
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,engine=&jsonengine)
|
|
140
|
+
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=YES)
|
|
138
141
|
data _null_; file &fref mod encoding='utf-8';
|
|
139
142
|
put "}";
|
|
140
143
|
%end;
|
|
@@ -163,6 +166,9 @@
|
|
|
163
166
|
put ',"SYSVLONG" : ' sysvlong;
|
|
164
167
|
put ",""SYSWARNINGTEXT"" : ""&syswarningtext"" ";
|
|
165
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;
|
|
166
172
|
put "}" @;
|
|
167
173
|
%if %str(&_debug) ge 131 %then %do;
|
|
168
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.2"
|
|
42
42
|
}
|
package/server/ms_webout.sas
CHANGED
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
@param [out] fref= (_webout) The fileref to which to write the JSON
|
|
28
28
|
@param [in] missing= (NULL) Special numeric missing values can be sent as NULL
|
|
29
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"}}`
|
|
30
34
|
|
|
31
35
|
<h4> SAS Macros </h4>
|
|
32
36
|
@li mp_jsonout.sas
|
|
@@ -41,7 +45,9 @@
|
|
|
41
45
|
|
|
42
46
|
**/
|
|
43
47
|
|
|
44
|
-
%macro ms_webout(action,ds,dslabel=,fref=_webout,fmt=Y,missing=NULL
|
|
48
|
+
%macro ms_webout(action,ds,dslabel=,fref=_webout,fmt=Y,missing=NULL
|
|
49
|
+
,showmeta=NO
|
|
50
|
+
);
|
|
45
51
|
%global _webin_file_count _webin_fileref1 _webin_name1 _program _debug
|
|
46
52
|
sasjs_tables;
|
|
47
53
|
|
|
@@ -93,7 +99,7 @@
|
|
|
93
99
|
|
|
94
100
|
%else %if &action=ARR or &action=OBJ %then %do;
|
|
95
101
|
%mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt,jref=&fref
|
|
96
|
-
,engine=DATASTEP,missing=&missing
|
|
102
|
+
,engine=DATASTEP,missing=&missing,showmeta=&showmeta
|
|
97
103
|
)
|
|
98
104
|
%end;
|
|
99
105
|
%else %if &action=CLOSE %then %do;
|
|
@@ -114,9 +120,6 @@
|
|
|
114
120
|
put ",""WORK"":{";
|
|
115
121
|
%do i=1 %to &wtcnt;
|
|
116
122
|
%let wt=&&wt&i;
|
|
117
|
-
proc contents noprint data=&wt
|
|
118
|
-
out=_data_ (keep=name type length format:);
|
|
119
|
-
run;%let tempds=%scan(&syslast,2,.);
|
|
120
123
|
data _null_; file &fref mod encoding='utf-8' termstr=lf;
|
|
121
124
|
dsid=open("WORK.&wt",'is');
|
|
122
125
|
nlobs=attrn(dsid,'NLOBS');
|
|
@@ -126,8 +129,7 @@
|
|
|
126
129
|
put " ""&wt"" : {";
|
|
127
130
|
put '"nlobs":' nlobs;
|
|
128
131
|
put ',"nvars":' nvars;
|
|
129
|
-
%mp_jsonout(OBJ,&
|
|
130
|
-
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,engine=DATASTEP)
|
|
132
|
+
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=YES)
|
|
131
133
|
data _null_; file &fref mod encoding='utf-8' termstr=lf;
|
|
132
134
|
put "}";
|
|
133
135
|
%end;
|