@sasjs/core 2.61.1 → 3.0.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.
@@ -29,45 +29,44 @@
29
29
 
30
30
  Usage:
31
31
 
32
- %mp_mdtablewrite(libds=sashelp.class,showlog=YES)
32
+ %mp_ds2md(sashelp.class)
33
33
 
34
+ @param [in] libds the library / dataset to create or read from.
35
+ @param [out] outref= (mdtable) Fileref to contain the markdown
36
+ @param [out] showlog= (YES) Set to NO to avoid printing markdown to the log
34
37
 
35
38
  <h4> SAS Macros </h4>
36
39
  @li mf_getvarlist.sas
37
40
  @li mf_getvarformat.sas
38
41
 
39
- @param [in] libds= the library / dataset to create or read from.
40
- @param [out] fref= Fileref to contain the markdown. Default=mdtable.
41
- @param [out] showlog= set to YES to show the markdown in the log. Default=NO.
42
-
43
42
  @version 9.3
44
43
  @author Allan Bowe
45
44
  **/
46
45
 
47
- %macro mp_mdtablewrite(
48
- libds=,
49
- fref=mdtable,
50
- showlog=NO
46
+ %macro mp_ds2md(
47
+ libds,
48
+ outref=mdtable,
49
+ showlog=YES
51
50
  )/*/STORE SOURCE*/;
52
51
 
53
52
  /* check fileref is assigned */
54
- %if %sysfunc(fileref(&fref)) > 0 %then %do;
55
- filename &fref temp;
53
+ %if %sysfunc(fileref(&outref)) > 0 %then %do;
54
+ filename &outref temp;
56
55
  %end;
57
56
 
58
57
  %local vars;
59
- %let vars=%mf_getvarlist(&libds);
58
+ %let vars=%upcase(%mf_getvarlist(&libds));
60
59
 
61
60
  /* create the header row */
62
61
  data _null_;
63
- file &fref;
62
+ file &outref;
64
63
  length line $32767;
65
64
  call missing(line);
66
65
  put '|'
67
66
  %local i var fmt;
68
67
  %do i=1 %to %sysfunc(countw(&vars));
69
68
  %let var=%scan(&vars,&i);
70
- %let fmt=%mf_getvarformat(&libds,&var,force=1);
69
+ %let fmt=%lowcase(%mf_getvarformat(&libds,&var,force=1));
71
70
  "&var:&fmt|"
72
71
  %end;
73
72
  ;
@@ -80,20 +79,20 @@ run;
80
79
 
81
80
  /* write out the data */
82
81
  data _null_;
83
- file &fref mod dlm='|' lrecl=32767;
82
+ file &outref mod dlm='|' lrecl=32767;
84
83
  set &libds ;
85
84
  length line $32767;
86
- line=cats('|',%mf_getvarlist(&libds,dlm=%str(,'|',)),'|');
85
+ line='|`'!!cats(%mf_getvarlist(&libds,dlm=%str(%)!!' `|`'!!cats%()))!!' `|';
87
86
  put line;
88
87
  run;
89
88
 
90
89
  %if %upcase(&showlog)=YES %then %do;
91
90
  options ps=max;
92
91
  data _null_;
93
- infile &fref;
92
+ infile &outref;
94
93
  input;
95
94
  putlog _infile_;
96
95
  run;
97
96
  %end;
98
97
 
99
- %mend mp_mdtablewrite;
98
+ %mend mp_ds2md;
@@ -23,7 +23,7 @@
23
23
  |---|---|---|---|---|---|---|---|---|---|---|---|---|
24
24
  | | | | |$|F|B|1|0|32767|0|1|0|
25
25
  | | | | |$|I|B|1|0|32767|0|1|0|
26
- | | |/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe|UWIANYDT|$ANYDTIF|I|U|1|0|60|0|19|0|
26
+ |` `|` `|/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe|UWIANYDT|$ANYDTIF|I|U|1|0|60|0|19|0|
27
27
  | | |/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe|UWFASCII|$ASCII|F|U|1|0|32767|0|1|0|
28
28
  | | |/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe|UWIASCII|$ASCII|I|U|1|0|32767|0|1|0|
29
29
  | | |/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe|UWFBASE6|$BASE64X|F|U|1|0|32767|0|1|0|
@@ -32,12 +32,12 @@
32
32
  @param [out] outdetail= (0) Provide an output dataset in which to export all
33
33
  the custom format definitions (from proc format CNTLOUT). Definitions:
34
34
  https://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473477.htm
35
- Sample data:
35
+ Sample data:
36
36
 
37
37
  |FMTNAME:$32.|START:$16.|END:$16.|LABEL:$256.|MIN:best.|MAX:best.|DEFAULT:best.|LENGTH:best.|FUZZ:best.|PREFIX:$2.|MULT:best.|FILL:$1.|NOEDIT:best.|TYPE:$1.|SEXCL:$1.|EEXCL:$1.|HLO:$13.|DECSEP:$1.|DIG3SEP:$1.|DATATYPE:$8.|LANGUAGE:$8.|
38
38
  |---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
39
- |WHICHPATH|0|0|path1|1|40|28|28|1E-12||0||0|N|N|N| | | | | |
40
- |WHICHPATH|`**OTHER**`|`**OTHER**`|big fat problem if not path1|1|40|28|28|1E-12||0||0|N|N|N|O| | | | |
39
+ |`WHICHPATH `|`0 `|`0 `|`path1 `|`1 `|`40 `|`28 `|`28 `|`1E-12 `|` `|`0 `|` `|`0 `|`N `|`N `|`N `|` `|` `|` `|` `|` `|
40
+ |`WHICHPATH `|`**OTHER** `|`**OTHER** `|`big fat problem if not path1 `|`1 `|`40 `|`28 `|`28 `|`1E-12 `|` `|`0 `|` `|`0 `|`N `|`N `|`N `|`O `|` `|` `|` `|` `|
41
41
 
42
42
  <h4> SAS Macros </h4>
43
43
  @li mf_dedup.sas
@@ -62,13 +62,13 @@
62
62
  %put output location=&jref;
63
63
  %if &action=OPEN %then %do;
64
64
  options nobomfile;
65
- data _null_;file &jref encoding='utf-8';
65
+ data _null_;file &jref encoding='utf-8' ;
66
66
  put '{"PROCESSED_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '"';
67
67
  run;
68
68
  %end;
69
69
  %else %if (&action=ARR or &action=OBJ) %then %do;
70
70
  options validvarname=upcase;
71
- data _null_;file &jref mod encoding='utf-8';
71
+ data _null_;file &jref mod encoding='utf-8' ;
72
72
  put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":";
73
73
 
74
74
  %if &engine=PROCJSON %then %do;
@@ -147,7 +147,7 @@
147
147
  run;
148
148
  %let ds=&fmtds;
149
149
  %end; /* &fmt=Y */
150
- data _null_;file &jref mod encoding='utf-8';
150
+ data _null_;file &jref mod encoding='utf-8' ;
151
151
  put "["; call symputx('cols',0,'l');
152
152
  proc sort
153
153
  data=sashelp.vcolumn(where=(libname='WORK' & memname="%upcase(&ds)"))
@@ -192,7 +192,7 @@
192
192
  /* write to temp loc to avoid _webout truncation
193
193
  - https://support.sas.com/kb/49/325.html */
194
194
  filename _sjs temp lrecl=131068 encoding='utf-8';
195
- data _null_; file _sjs lrecl=131068 encoding='utf-8' mod;
195
+ data _null_; file _sjs lrecl=131068 encoding='utf-8' mod ;
196
196
  set &tempds;
197
197
  if _n_>1 then put "," @; put
198
198
  %if &action=ARR %then "[" ; %else "{" ;
@@ -219,14 +219,14 @@
219
219
  rc = fclose(fileid);
220
220
  run;
221
221
  filename _sjs clear;
222
- data _null_; file &jref mod encoding='utf-8';
222
+ data _null_; file &jref mod encoding='utf-8' ;
223
223
  put "]";
224
224
  run;
225
225
  %end;
226
226
  %end;
227
227
 
228
228
  %else %if &action=CLOSE %then %do;
229
- data _null_;file &jref encoding='utf-8' mod;
229
+ data _null_;file &jref encoding='utf-8' mod ;
230
230
  put "}";
231
231
  run;
232
232
  %end;
@@ -70,7 +70,7 @@ data &ds1;
70
70
  %end;
71
71
 
72
72
  %let numvars=%mf_getvarlist(&libds,typefilter=N);
73
- %if &numvars ^= %then %do i=1 %to %sysfunc(countw(&numvars));
73
+ %if &numvars ^= %then %do i=1 %to %sysfunc(countw(&numvars));
74
74
  %let col=%scan(&numvars,&i);
75
75
  &col=&n1;
76
76
  %end;
@@ -3,13 +3,15 @@
3
3
  @brief Reset an option to original value
4
4
  @details Inspired by the SAS Jedi -
5
5
  https://blogs.sas.com/content/sastraining/2012/08/14/jedi-sas-tricks-reset-sas-system-options
6
- Called as follows:
7
6
 
8
- options obs=30;
9
- %mp_resetoption(OBS)
7
+ Called as follows:
10
8
 
9
+ options obs=30 ps=max;
10
+ %mp_resetoption(OBS)
11
+ %mp_resetoption(PS)
11
12
 
12
- @param option the option to reset
13
+
14
+ @param [in] option the option to reset
13
15
 
14
16
  @version 9.2
15
17
  @author Allan Bowe
@@ -11,9 +11,7 @@
11
11
 
12
12
  This macro will only work for BASE (V9) engine libraries. It works by
13
13
  creating a copy of the dataset (without data, WITH constraints) in the same
14
- library, appending a sorted view into it, and finally - renaming it. By
15
- default, COMPRESS=CHAR and REUSE=YES will be applied, this behaviour can
16
- be adjusted using the `dsoptions=` parameter.
14
+ library, appending a sorted view into it, and finally - renaming it.
17
15
 
18
16
  Example usage:
19
17
 
@@ -41,7 +39,6 @@
41
39
 
42
40
  @version 9.2
43
41
  @author Allan Bowe
44
- @source https://github.com/sasjs/core
45
42
 
46
43
  **/
47
44
 
@@ -295,7 +295,7 @@ run;
295
295
  prop='Connection.DBMS.Property.SERVER.Name.xmlKey.txt';
296
296
  rc=metadata_getprop(uri,prop,server,"");
297
297
  end;
298
- if server^='' then server='server='!!server;
298
+ if server^='' then server='server='!!quote(cats(server));
299
299
  call symputx('server',server,'l');
300
300
 
301
301
  /* get SCHEMA value */
@@ -441,11 +441,11 @@ run;
441
441
  run;
442
442
 
443
443
  %put NOTE: Executing the following:/; %put NOTE-;
444
- %put NOTE- libname &libref TERADATA server=&path schema=&schema ;
444
+ %put NOTE- libname &libref TERADATA server="&path" schema=&schema ;
445
445
  %put NOTe- authdomain=&authdomain;
446
446
  %put NOTE-;
447
447
 
448
- libname &libref TERADATA server=&path schema=&schema authdomain=&authdomain;
448
+ libname &libref TERADATA server="&path" schema=&schema authdomain=&authdomain;
449
449
  %end;
450
450
  %else %if &engine= %then %do;
451
451
  %put NOTE: Libref &libref is not registered in metadata;
@@ -94,13 +94,13 @@ data _null_;
94
94
  put '%put output location=&jref; ';
95
95
  put '%if &action=OPEN %then %do; ';
96
96
  put ' options nobomfile; ';
97
- put ' data _null_;file &jref encoding=''utf-8''; ';
97
+ put ' data _null_;file &jref encoding=''utf-8'' ; ';
98
98
  put ' put ''{"PROCESSED_DTTM" : "'' "%sysfunc(datetime(),E8601DT26.6)" ''"''; ';
99
99
  put ' run; ';
100
100
  put '%end; ';
101
101
  put '%else %if (&action=ARR or &action=OBJ) %then %do; ';
102
102
  put ' options validvarname=upcase; ';
103
- put ' data _null_;file &jref mod encoding=''utf-8''; ';
103
+ put ' data _null_;file &jref mod encoding=''utf-8'' ; ';
104
104
  put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
105
105
  put ' ';
106
106
  put ' %if &engine=PROCJSON %then %do; ';
@@ -179,7 +179,7 @@ data _null_;
179
179
  put ' run; ';
180
180
  put ' %let ds=&fmtds; ';
181
181
  put ' %end; /* &fmt=Y */ ';
182
- put ' data _null_;file &jref mod encoding=''utf-8''; ';
182
+ put ' data _null_;file &jref mod encoding=''utf-8'' ; ';
183
183
  put ' put "["; call symputx(''cols'',0,''l''); ';
184
184
  put ' proc sort ';
185
185
  put ' data=sashelp.vcolumn(where=(libname=''WORK'' & memname="%upcase(&ds)")) ';
@@ -224,7 +224,7 @@ data _null_;
224
224
  put ' /* write to temp loc to avoid _webout truncation ';
225
225
  put ' - https://support.sas.com/kb/49/325.html */ ';
226
226
  put ' filename _sjs temp lrecl=131068 encoding=''utf-8''; ';
227
- put ' data _null_; file _sjs lrecl=131068 encoding=''utf-8'' mod; ';
227
+ put ' data _null_; file _sjs lrecl=131068 encoding=''utf-8'' mod ; ';
228
228
  put ' set &tempds; ';
229
229
  put ' if _n_>1 then put "," @; put ';
230
230
  put ' %if &action=ARR %then "[" ; %else "{" ; ';
@@ -251,14 +251,14 @@ data _null_;
251
251
  put ' rc = fclose(fileid); ';
252
252
  put ' run; ';
253
253
  put ' filename _sjs clear; ';
254
- put ' data _null_; file &jref mod encoding=''utf-8''; ';
254
+ put ' data _null_; file &jref mod encoding=''utf-8'' ; ';
255
255
  put ' put "]"; ';
256
256
  put ' run; ';
257
257
  put ' %end; ';
258
258
  put '%end; ';
259
259
  put ' ';
260
260
  put '%else %if &action=CLOSE %then %do; ';
261
- put ' data _null_;file &jref encoding=''utf-8'' mod; ';
261
+ put ' data _null_;file &jref encoding=''utf-8'' mod ; ';
262
262
  put ' put "}"; ';
263
263
  put ' run; ';
264
264
  put '%end; ';
package/package.json CHANGED
@@ -38,5 +38,5 @@
38
38
  "dependencies": {
39
39
  "ts-loader": "^9.2.6"
40
40
  },
41
- "version": "2.61.1"
41
+ "version": "3.0.3"
42
42
  }
@@ -79,7 +79,7 @@
79
79
  OPTIONS NOBOMFILE;
80
80
 
81
81
  /* setup json */
82
- data _null_;file &fref encoding='utf-8';
82
+ data _null_;file &fref encoding='utf-8' termstr=lf;
83
83
  %if %str(&_debug) ge 131 %then %do;
84
84
  put '>>weboutBEGIN<<';
85
85
  %end;
@@ -108,14 +108,14 @@
108
108
  i+1;
109
109
  call symputx('wt'!!left(i),name,'l');
110
110
  call symputx('wtcnt',i,'l');
111
- data _null_; file &fref mod encoding='utf-8';
111
+ data _null_; file &fref mod encoding='utf-8' termstr=lf;
112
112
  put ",""WORK"":{";
113
113
  %do i=1 %to &wtcnt;
114
114
  %let wt=&&wt&i;
115
115
  proc contents noprint data=&wt
116
116
  out=_data_ (keep=name type length format:);
117
117
  run;%let tempds=%scan(&syslast,2,.);
118
- data _null_; file &fref mod encoding='utf-8';
118
+ data _null_; file &fref mod encoding='utf-8' termstr=lf;
119
119
  dsid=open("WORK.&wt",'is');
120
120
  nlobs=attrn(dsid,'NLOBS');
121
121
  nvars=attrn(dsid,'NVARS');
@@ -126,15 +126,15 @@
126
126
  put ',"nvars":' nvars;
127
127
  %mp_jsonout(OBJ,&tempds,jref=&fref,dslabel=colattrs,engine=DATASTEP)
128
128
  %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,engine=DATASTEP)
129
- data _null_; file &fref mod encoding='utf-8';
129
+ data _null_; file &fref mod encoding='utf-8' termstr=lf;
130
130
  put "}";
131
131
  %end;
132
- data _null_; file &fref mod encoding='utf-8';
132
+ data _null_; file &fref mod encoding='utf-8' termstr=lf termstr=lf;
133
133
  put "}";
134
134
  run;
135
135
  %end;
136
136
  /* close off json */
137
- data _null_;file &fref mod encoding='utf-8';
137
+ data _null_;file &fref mod encoding='utf-8' termstr=lf;
138
138
  _PROGRAM=quote(trim(resolve(symget('_PROGRAM'))));
139
139
  put ",""SYSUSERID"" : ""&sysuserid"" ";
140
140
  put ",""MF_GETUSER"" : ""%mf_getuser()"" ";
@@ -147,7 +147,9 @@
147
147
  put ",""SYSHOSTNAME"" : ""&syshostname"" ";
148
148
  put ",""SYSPROCESSID"" : ""&SYSPROCESSID"" ";
149
149
  put ",""SYSPROCESSMODE"" : ""&SYSPROCESSMODE"" ";
150
- put ",""SYSPROCESSNAME"" : ""&SYSPROCESSNAME"" ";
150
+ length SYSPROCESSNAME $512;
151
+ SYSPROCESSNAME=quote(urlencode(cats(SYSPROCESSNAME)));
152
+ put ",""SYSPROCESSNAME"" : " SYSPROCESSNAME;
151
153
  put ",""SYSJOBID"" : ""&sysjobid"" ";
152
154
  put ",""SYSSCPL"" : ""&sysscpl"" ";
153
155
  put ",""SYSSITE"" : ""&syssite"" ";
@@ -156,7 +158,8 @@
156
158
  put ',"SYSVLONG" : ' sysvlong;
157
159
  put ",""SYSWARNINGTEXT"" : ""&syswarningtext"" ";
158
160
  put ',"END_DTTM" : "' "%sysfunc(datetime(),datetime20.3)" '" ';
159
- autoexec=quote(trim(getoption('autoexec')));
161
+ length autoexec $512;
162
+ autoexec=quote(urlencode(trim(getoption('autoexec'))));
160
163
  put ',"AUTOEXEC" : ' autoexec;
161
164
  memsize="%sysfunc(INPUTN(%sysfunc(getoption(memsize)), best.),sizekmg.)";
162
165
  memsize=quote(cats(memsize));
@@ -242,13 +242,13 @@ data _null_;
242
242
  put '%put output location=&jref; ';
243
243
  put '%if &action=OPEN %then %do; ';
244
244
  put ' options nobomfile; ';
245
- put ' data _null_;file &jref encoding=''utf-8''; ';
245
+ put ' data _null_;file &jref encoding=''utf-8'' ; ';
246
246
  put ' put ''{"PROCESSED_DTTM" : "'' "%sysfunc(datetime(),E8601DT26.6)" ''"''; ';
247
247
  put ' run; ';
248
248
  put '%end; ';
249
249
  put '%else %if (&action=ARR or &action=OBJ) %then %do; ';
250
250
  put ' options validvarname=upcase; ';
251
- put ' data _null_;file &jref mod encoding=''utf-8''; ';
251
+ put ' data _null_;file &jref mod encoding=''utf-8'' ; ';
252
252
  put ' put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":"; ';
253
253
  put ' ';
254
254
  put ' %if &engine=PROCJSON %then %do; ';
@@ -327,7 +327,7 @@ data _null_;
327
327
  put ' run; ';
328
328
  put ' %let ds=&fmtds; ';
329
329
  put ' %end; /* &fmt=Y */ ';
330
- put ' data _null_;file &jref mod encoding=''utf-8''; ';
330
+ put ' data _null_;file &jref mod encoding=''utf-8'' ; ';
331
331
  put ' put "["; call symputx(''cols'',0,''l''); ';
332
332
  put ' proc sort ';
333
333
  put ' data=sashelp.vcolumn(where=(libname=''WORK'' & memname="%upcase(&ds)")) ';
@@ -372,7 +372,7 @@ data _null_;
372
372
  put ' /* write to temp loc to avoid _webout truncation ';
373
373
  put ' - https://support.sas.com/kb/49/325.html */ ';
374
374
  put ' filename _sjs temp lrecl=131068 encoding=''utf-8''; ';
375
- put ' data _null_; file _sjs lrecl=131068 encoding=''utf-8'' mod; ';
375
+ put ' data _null_; file _sjs lrecl=131068 encoding=''utf-8'' mod ; ';
376
376
  put ' set &tempds; ';
377
377
  put ' if _n_>1 then put "," @; put ';
378
378
  put ' %if &action=ARR %then "[" ; %else "{" ; ';
@@ -399,14 +399,14 @@ data _null_;
399
399
  put ' rc = fclose(fileid); ';
400
400
  put ' run; ';
401
401
  put ' filename _sjs clear; ';
402
- put ' data _null_; file &jref mod encoding=''utf-8''; ';
402
+ put ' data _null_; file &jref mod encoding=''utf-8'' ; ';
403
403
  put ' put "]"; ';
404
404
  put ' run; ';
405
405
  put ' %end; ';
406
406
  put '%end; ';
407
407
  put ' ';
408
408
  put '%else %if &action=CLOSE %then %do; ';
409
- put ' data _null_;file &jref encoding=''utf-8'' mod; ';
409
+ put ' data _null_;file &jref encoding=''utf-8'' mod ; ';
410
410
  put ' put "}"; ';
411
411
  put ' run; ';
412
412
  put '%end; ';