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