@sasjs/core 3.10.0 → 4.0.0

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 CHANGED
@@ -125,6 +125,7 @@ filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
125
125
  - macro names must be lowercase
126
126
  - one macro per file
127
127
  - prefixes:
128
+ - _mcf_ for macro compiled functions (proc fcmp)
128
129
  - _mf_ for macro functions (can be used in open code).
129
130
  - _ml_ for macros that are used to compile LUA modules
130
131
  - _mm_ for metadata macros (interface with the metadata server).
@@ -166,7 +167,7 @@ SAS code can contain one of two types of dependency - SAS Macros, and SAS Includ
166
167
  @li someprogram.sas FREFTWO
167
168
  ```
168
169
 
169
- The CLI can then extract all the dependencies and insert as precode (SAS Macros) or in a temp engine fileref (SAS Includes) when creating SAS Jobs and Services.
170
+ The CLI can then extract all the dependencies and insert as precode (SAS Macros) or in a temp engine fileref (SAS Includes) when creating SAS Jobs and Services (and Tests).
170
171
 
171
172
  When contributing to this library, it is therefore important to ensure that all dependencies are listed in the header in this format.
172
173
 
@@ -182,7 +183,9 @@ When contributing to this library, it is therefore important to ensure that all
182
183
  - Mandatory parameters should be positional, all optional parameters should be keyword (var=) style.
183
184
  - All dataset references must be 2 level (eg `work.blah`, not `blah`). This is to avoid contention when options [DATASTMTCHK](https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000279064.htm)=ALLKEYWORDS is in effect.
184
185
  - Avoid naming collisions! All macro variables should be local scope. Use system generated work tables where possible - eg `data ; set sashelp.class; run; data &output; set &syslast; run;`
186
+ - Where global macro variables are absolutely necessary, they should make use of `&sasjs_prefix` - see mp_init.sas
185
187
  - The use of `quit;` for `proc sql` is optional unless you are looking to benefit from the timing statistics.
188
+ - Use [sasjs lint](https://github.com/sasjs/lint)!
186
189
 
187
190
  ## General Notes
188
191
 
@@ -190,10 +193,9 @@ When contributing to this library, it is therefore important to ensure that all
190
193
 
191
194
  ## Breaking Changes
192
195
 
193
- We are currently on major release v3. The following changes are planned when the next major (breaking) release becomes necessary:
196
+ We are currently on major release v4. Breaking changes should be marked with the [deprecated](https://www.doxygen.nl/manual/commands.html#cmddeprecated) doxygen tag. The following changes are planned when the next major (breaking) release becomes necessary:
194
197
 
195
- * Remove `dbg` parameter from mp_jsonout.sas (implement mdebug instead)
196
- * Remove `END_DTTM` and `START_DTTM` from mx_webout JSON
198
+ * (None as yet)
197
199
 
198
200
  ## Star Gazing
199
201
 
package/base/mf_abort.sas CHANGED
@@ -11,7 +11,7 @@
11
11
  @cond
12
12
  **/
13
13
 
14
- %macro mf_abort(mac=mf_abort.sas, type=deprecated, msg=, iftrue=%str(1=1)
14
+ %macro mf_abort(mac=mf_abort.sas, msg=, iftrue=%str(1=1)
15
15
  )/*/STORE SOURCE*/;
16
16
 
17
17
  %if not(%eval(%unquote(&iftrue))) %then %return;
package/base/mp_abort.sas CHANGED
@@ -173,7 +173,8 @@
173
173
  if symexist('_debug') then debug=quote(trim(symget('_debug')));
174
174
  else debug='""';
175
175
  put '>>weboutBEGIN<<';
176
- put '{"START_DTTM" : "' "%sysfunc(datetime(),datetime20.3)" '"';
176
+ put '{"SYSDATE" : "' "&SYSDATE" '"';
177
+ put ',"SYSTIME" : "' "&SYSTIME" '"';
177
178
  put ',"sasjsAbort" : [{';
178
179
  put ' "MSG":' msg ;
179
180
  put ' ,"MAC": "' "&mac" '"}]';
@@ -202,7 +203,7 @@
202
203
  put ',"SYSVLONG" : ' sysvlong;
203
204
  syswarningtext=quote(trim(symget('syswarningtext')));
204
205
  put ",""SYSWARNINGTEXT"" : " syswarningtext;
205
- put ',"END_DTTM" : "' "%sysfunc(datetime(),datetime20.3)" '" ';
206
+ put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
206
207
  put "}" @;
207
208
  put '>>weboutEND<<';
208
209
  run;
@@ -0,0 +1,119 @@
1
+ /**
2
+ @file
3
+ @brief Used to capture scope leakage of macro variables
4
+ @details A common 'difficult to detect' bug in macros is where a nested
5
+ macro over-writes variables in a higher level macro.
6
+
7
+ This assertion takes a snapshot of the macro variables before and after
8
+ a macro invocation. This makes it easy to detect whether any macro
9
+ variables were modified or changed.
10
+
11
+ Currently, the macro only checks for global scope variables. In the future
12
+ it may be extended to work at multiple levels of nesting.
13
+
14
+ If you would like this feature, feel free to contribute / raise an issue /
15
+ engage the SASjs team directly.
16
+
17
+ Example usage:
18
+
19
+ %mp_assertscope(SNAPSHOT)
20
+
21
+ %let oops=I did it again;
22
+
23
+ %mp_assertscope(COMPARE,
24
+ desc=Checking macro variables against previous snapshot
25
+ )
26
+
27
+ @param [in] action (SNAPSHOT) The action to take. Valid values:
28
+ @li SNAPSHOT - take a copy of the current macro variables
29
+ @li COMPARE - compare the current macro variables against previous values
30
+ @param [in] scope= (GLOBAL) The scope of the variables to be checked. This
31
+ corresponds to the values in the SCOPE column in `sashelp.vmacro`.
32
+ @param [in] desc= (Testing scope leakage) The user provided test description
33
+ @param [in,out] scopeds= (work.mp_assertscope) The dataset to contain the
34
+ scope snapshot
35
+ @param [out] outds= (work.test_results) The output dataset to contain the
36
+ results. If it does not exist, it will be created, with the following format:
37
+ |TEST_DESCRIPTION:$256|TEST_RESULT:$4|TEST_COMMENTS:$256|
38
+ |---|---|---|
39
+ |User Provided description|PASS|No out of scope variables created or modified|
40
+
41
+ <h4> Related Macros </h4>
42
+ @li mp_assert.sas
43
+ @li mp_assertcols.sas
44
+ @li mp_assertcolvals.sas
45
+ @li mp_assertdsobs.sas
46
+ @li mp_assertscope.test.sas
47
+
48
+ @version 9.2
49
+ @author Allan Bowe
50
+
51
+ **/
52
+
53
+ %macro mp_assertscope(action,
54
+ desc=Testing Scope Leakage,
55
+ scope=GLOBAL,
56
+ scopeds=work.mp_assertscope,
57
+ outds=work.test_results
58
+ )/*/STORE SOURCE*/;
59
+ %local ds test_result test_comments del add mod;
60
+
61
+ /* get current variables */
62
+ %if &action=SNAPSHOT %then %do;
63
+ proc sql;
64
+ create table &scopeds as
65
+ select name,offset,value
66
+ from dictionary.macros
67
+ where scope="&scope"
68
+ order by name,offset;
69
+ %end;
70
+ %else %if &action=COMPARE %then %do;
71
+
72
+ proc sql;
73
+ create table _data_ as
74
+ select name,offset,value
75
+ from dictionary.macros
76
+ where scope="&scope"
77
+ order by name,offset;
78
+
79
+ %let ds=&syslast;
80
+
81
+ proc compare base=&scopeds compare=&ds;
82
+ run;
83
+
84
+ %if &sysinfo=0 %then %do;
85
+ %let test_result=PASS;
86
+ %let test_comments=&scope Variables Unmodified;
87
+ %end;
88
+ %else %do;
89
+ proc sql noprint undo_policy=none;
90
+ select distinct name into: del separated by ' ' from &scopeds
91
+ where name not in (select name from &ds);
92
+ select distinct name into: add separated by ' ' from &ds
93
+ where name not in (select name from &scopeds);
94
+ select distinct a.name into: mod separated by ' '
95
+ from &scopeds a
96
+ inner join &ds b
97
+ on a.name=b.name
98
+ and a.offset=b.offset
99
+ where a.value ne b.value;
100
+ %let test_result=FAIL;
101
+ %let test_comments=%str(Mod:(&mod) Add:(&add) Del:(&del));
102
+ %end;
103
+
104
+
105
+ data ;
106
+ length test_description $256 test_result $4 test_comments $256;
107
+ test_description=symget('desc');
108
+ test_comments=symget('test_comments');
109
+ test_result=symget('test_result');
110
+ run;
111
+
112
+ %let ds=&syslast;
113
+ proc append base=&outds data=&ds;
114
+ run;
115
+ proc sql;
116
+ drop table &ds;
117
+ %end;
118
+
119
+ %mend mp_assertscope;
@@ -0,0 +1,119 @@
1
+ /**
2
+ @file
3
+ @brief Create a smaller version of a dataset, without data loss
4
+ @details This macro will scan the input dataset and create a new one, that
5
+ has the minimum variable lengths needed to store the data without data loss.
6
+
7
+ Inspiration was taken from [How to Reduce the Disk Space Required by a
8
+ SAS® Data Set](https://www.lexjansen.com/nesug/nesug06/io/io18.pdf) by
9
+ Selvaratnam Sridharma. The end of the referenced paper presents a macro named
10
+ "squeeze", hence the nomenclature.
11
+
12
+ Usage:
13
+
14
+ data big;
15
+ length my big $32000;
16
+ do i=1 to 1e4;
17
+ my=repeat('oh my',100);
18
+ big='dawg';
19
+ special=._;
20
+ output;
21
+ end;
22
+ run;
23
+
24
+ %mp_ds2squeeze(work.big,outds=work.smaller)
25
+
26
+ The following will also be printed to the log (exact values may differ
27
+ depending on your OS and COMPRESS settings):
28
+
29
+ > MP_DS2SQUEEZE: work.big was 625MB
30
+
31
+ > MP_DS2SQUEEZE: work.smaller is 5MB
32
+
33
+ @param [in] libds The library.dataset to be squeezed
34
+ @param [out] outds= (work.mp_ds2squeeze) The squeezed dataset to create
35
+ @param [in] mdebug= (0) Set to 1 to enable DEBUG messages
36
+
37
+ <h4> SAS Macros </h4>
38
+ @li mf_getfilesize.sas
39
+ @li mf_getuniquefileref.sas
40
+ @li mf_getuniquename.sas
41
+ @li mp_getmaxvarlengths.sas
42
+
43
+ <h4> Related Programs </h4>
44
+ @li mp_ds2squeeze.test.sas
45
+
46
+ @version 9.3
47
+ @author Allan Bowe
48
+ **/
49
+
50
+ %macro mp_ds2squeeze(
51
+ libds,
52
+ outds=work.work.mp_ds2squeeze,
53
+ mdebug=0
54
+ )/*/STORE SOURCE*/;
55
+ %local dbg source;
56
+ %if &mdebug=1 %then %do;
57
+ %put &sysmacroname entry vars:;
58
+ %put _local_;
59
+ %end;
60
+ %else %do;
61
+ %let dbg=*;
62
+ %let source=/source2;
63
+ %end;
64
+
65
+ %local optval ds fref;
66
+ %let ds=%mf_getuniquename();
67
+ %let fref=%mf_getuniquefileref();
68
+
69
+ %mp_getmaxvarlengths(&libds,outds=&ds)
70
+
71
+ data _null_;
72
+ set &ds end=last;
73
+ file &fref;
74
+ /* grab the types */
75
+ retain dsid;
76
+ if _n_=1 then dsid=open("&libds",'is');
77
+ if dsid le 0 then do;
78
+ msg=sysmsg();
79
+ put msg=;
80
+ stop;
81
+ end;
82
+ type=vartype(dsid,varnum(dsid, name));
83
+ if last then rc=close(dsid);
84
+ /* write out the length statement */
85
+ if _n_=1 then put 'length ';
86
+ length len $6;
87
+ if type='C' then do;
88
+ if maxlen=0 then len='$1';
89
+ else len=cats('$',maxlen);
90
+ end;
91
+ else do;
92
+ if maxlen=0 then len='3';
93
+ else len=cats(maxlen);
94
+ end;
95
+ put ' ' name ' ' len;
96
+ if last then put ';';
97
+ run;
98
+
99
+ /* configure varlenchk - as we are explicitly shortening the variables */
100
+ %let optval=%sysfunc(getoption(varlenchk));
101
+ options varlenchk=NOWARN;
102
+
103
+ data &outds;
104
+ %inc &fref &source;
105
+ set &libds;
106
+ run;
107
+
108
+ options varlenchk=&optval;
109
+
110
+ %if &mdebug=0 %then %do;
111
+ proc sql;
112
+ drop table &ds;
113
+ filename &fref clear;
114
+ %end;
115
+
116
+ %put &sysmacroname: &libds was %mf_getfilesize(libds=&libds,format=yes);
117
+ %put &sysmacroname: &outds is %mf_getfilesize(libds=&outds,format=yes);
118
+
119
+ %mend mp_ds2squeeze;
@@ -1,28 +1,46 @@
1
1
  /**
2
- @file mp_getmaxvarlengths.sas
2
+ @file
3
3
  @brief Scans a dataset to find the max length of the variable values
4
4
  @details
5
5
  This macro will scan a base dataset and produce an output dataset with two
6
6
  columns:
7
7
 
8
8
  - NAME Name of the base dataset column
9
- - MAXLEN Maximum length of the data contained therein.
9
+ - MAXLEN Maximum length of the data contained therein.
10
10
 
11
- Character fields may be allocated very large widths (eg 32000) of which the
12
- maximum value is likely to be much narrower. This macro was designed to
13
- enable a HTML table to be appropriately sized however this could be used as
14
- part of a data audit to ensure we aren't over-sizing our tables in relation to
15
- the data therein.
11
+ Character fields are often allocated very large widths (eg 32000) of which the
12
+ maximum value is likely to be much narrower. Identifying such cases can be
13
+ helpful in the following scenarios:
14
+
15
+ @li Enabling a HTML table to be appropriately sized (`num2char=YES`)
16
+ @li Reducing the size of a dataset to save on storage (mp_ds2squeeze.sas)
17
+ @li Identifying columns containing nothing but missing values (`MAXLEN=0` in
18
+ the output table)
19
+
20
+ If the entire column is made up of (non-special) missing values then a value
21
+ of 0 is returned.
16
22
 
17
- Numeric fields are converted using the relevant format to determine the width.
18
23
  Usage:
19
24
 
20
25
  %mp_getmaxvarlengths(sashelp.class,outds=work.myds)
21
26
 
22
- @param libds Two part dataset (or view) reference.
23
- @param outds= The output dataset to create
27
+ @param [in] libds Two part dataset (or view) reference.
28
+ @param [in] num2char= (NO) When set to NO, numeric fields are sized according
29
+ to the number of bytes used (or set to zero in the case of non-special
30
+ missings). When YES, the numeric field is converted to character (using the
31
+ format, if available), and that is sized instead, using `lengthn()`.
32
+ @param [out] outds= The output dataset to create, eg:
33
+ |NAME:$8.|MAXLEN:best.|
34
+ |---|---|
35
+ |`Name `|`7 `|
36
+ |`Sex `|`1 `|
37
+ |`Age `|`3 `|
38
+ |`Height `|`8 `|
39
+ |`Weight `|`3 `|
24
40
 
25
41
  <h4> SAS Macros </h4>
42
+ @li mcf_length.sas
43
+ @li mf_getuniquename.sas
26
44
  @li mf_getvarlist.sas
27
45
  @li mf_getvartype.sas
28
46
  @li mf_getvarformat.sas
@@ -30,20 +48,32 @@
30
48
  @version 9.2
31
49
  @author Allan Bowe
32
50
 
51
+ <h4> Related Macros </h4>
52
+ @li mp_ds2squeeze.sas
53
+ @li mp_getmaxvarlengths.test.sas
54
+
33
55
  **/
34
56
 
35
57
  %macro mp_getmaxvarlengths(
36
- libds /* libref.dataset to analyse */
37
- ,outds=work.mp_getmaxvarlengths /* name of output dataset to create */
58
+ libds
59
+ ,num2char=NO
60
+ ,outds=work.mp_getmaxvarlengths
38
61
  )/*/STORE SOURCE*/;
39
62
 
40
- %local vars x var fmt;
63
+ %local vars prefix x var fmt;
41
64
  %let vars=%mf_getvarlist(libds=&libds);
65
+ %let prefix=%substr(%mf_getuniquename(),1,25);
66
+ %let num2char=%upcase(&num2char);
67
+
68
+ %if &num2char=NO %then %do;
69
+ /* compile length function for numeric fields */
70
+ %mcf_length(wrap=YES, insert_cmplib=YES)
71
+ %end;
42
72
 
43
73
  proc sql;
44
74
  create table &outds (rename=(
45
75
  %do x=1 %to %sysfunc(countw(&vars,%str( )));
46
- ________&x=%scan(&vars,&x)
76
+ &prefix.&x=%scan(&vars,&x)
47
77
  %end;
48
78
  ))
49
79
  as select
@@ -51,18 +81,21 @@ create table &outds (rename=(
51
81
  %let var=%scan(&vars,&x);
52
82
  %if &x>1 %then ,;
53
83
  %if %mf_getvartype(&libds,&var)=C %then %do;
54
- max(length(&var)) as ________&x
84
+ max(lengthn(&var)) as &prefix.&x
55
85
  %end;
56
- %else %do;
86
+ %else %if &num2char=YES %then %do;
57
87
  %let fmt=%mf_getvarformat(&libds,&var);
58
88
  %put fmt=&fmt;
59
89
  %if %str(&fmt)=%str() %then %do;
60
- max(length(cats(&var))) as ________&x
90
+ max(lengthn(cats(&var))) as &prefix.&x
61
91
  %end;
62
92
  %else %do;
63
- max(length(put(&var,&fmt))) as ________&x
93
+ max(lengthn(put(&var,&fmt))) as &prefix.&x
64
94
  %end;
65
95
  %end;
96
+ %else %do;
97
+ max(mcf_length(&var)) as &prefix.&x
98
+ %end;
66
99
  %end;
67
100
  from &libds;
68
101
 
package/base/mp_init.sas CHANGED
@@ -33,37 +33,41 @@
33
33
  %macro mp_init(prefix=SASJS
34
34
  )/*/STORE SOURCE*/;
35
35
 
36
- %global
37
- &prefix._INIT_NUM /* initialisation time as numeric */
38
- &prefix._INIT_DTTM /* initialisation time in E8601DT26.6 format */
39
- &prefix.WORK /* avoid typing %sysfunc(pathname(work)) every time */
40
- ;
41
- %if %eval(&&&prefix._INIT_NUM>0) %then %return; /* only run once */
42
-
43
- data _null_;
44
- dttm=datetime();
45
- call symputx("&prefix._init_num",dttm,'g');
46
- call symputx("&prefix._init_dttm",put(dttm,E8601DT26.6),'g');
47
- call symputx("&prefix.work",pathname('WORK'),'g');
48
- run;
49
-
50
- options
51
- noautocorrect /* disallow misspelled procedure names */
52
- compress=CHAR /* default is none so ensure we have something! */
53
- datastmtchk=ALLKEYWORDS /* protection from overwriting input datasets */
54
- dsoptions=note2err /* undocumented - convert bad NOTEs to ERRs */
55
- %str(err)orcheck=STRICT /* catch errs in libname/filename statements */
56
- fmterr /* ensure err when a format cannot be found */
57
- mergenoby=%str(ERR)OR /* throw err when a merge has no BY variables */
58
- missing=. /* changing this can cause hard to detect errs */
59
- noquotelenmax /* avoid warnings for long strings */
60
- noreplace /* avoid overwriting permanent datasets */
61
- ps=max /* reduce log size slightly */
62
- ls=max /* reduce log even more and avoid word truncation */
63
- validmemname=COMPATIBLE /* avoid special characters etc in table names */
64
- validvarname=V7 /* avoid special characters etc in variable names */
65
- varinitchk=%str(ERR)OR /* avoid data mistakes from variable name typos */
66
- varlenchk=%str(ERR)OR /* fail hard if truncation (data loss) can result */
67
- ;
36
+ %if %symexist(SASJS_PREFIX) %then %return; /* only run once */
37
+
38
+ %global
39
+ SASJS_PREFIX /* the ONLY hard-coded global macro variable in SASjs */
40
+ &prefix._INIT_NUM /* initialisation time as numeric */
41
+ &prefix._INIT_DTTM /* initialisation time in E8601DT26.6 format */
42
+ &prefix.WORK /* avoid typing %sysfunc(pathname(work)) every time */
43
+ ;
44
+
45
+ %let sasjs_prefix=&prefix;
46
+
47
+ data _null_;
48
+ dttm=datetime();
49
+ call symputx("&sasjs_prefix._init_num",dttm,'g');
50
+ call symputx("&sasjs_prefix._init_dttm",put(dttm,E8601DT26.6),'g');
51
+ call symputx("&sasjs_prefix.work",pathname('WORK'),'g');
52
+ run;
53
+
54
+ options
55
+ noautocorrect /* disallow misspelled procedure names */
56
+ compress=CHAR /* default is none so ensure we have something! */
57
+ datastmtchk=ALLKEYWORDS /* protection from overwriting input datasets */
58
+ dsoptions=note2err /* undocumented - convert bad NOTEs to ERRs */
59
+ %str(err)orcheck=STRICT /* catch errs in libname/filename statements */
60
+ fmterr /* ensure err when a format cannot be found */
61
+ mergenoby=%str(ERR)OR /* throw err when a merge has no BY variables */
62
+ missing=. /* changing this can cause hard to detect errs */
63
+ noquotelenmax /* avoid warnings for long strings */
64
+ noreplace /* avoid overwriting permanent datasets */
65
+ ps=max /* reduce log size slightly */
66
+ ls=max /* reduce log even more and avoid word truncation */
67
+ validmemname=COMPATIBLE /* avoid special characters etc in table names */
68
+ validvarname=V7 /* avoid special characters etc in variable names */
69
+ varinitchk=%str(ERR)OR /* avoid data mistakes from variable name typos */
70
+ varlenchk=%str(ERR)OR /* fail hard if truncation (data loss) can result */
71
+ ;
68
72
 
69
73
  %mend mp_init;
@@ -62,7 +62,6 @@
62
62
 
63
63
  %macro mp_jsonout(action,ds,jref=_webout,dslabel=,fmt=Y
64
64
  ,engine=DATASTEP
65
- ,dbg=0 /* DEPRECATED */
66
65
  ,missing=NULL
67
66
  ,showmeta=NO
68
67
  )/*/STORE SOURCE*/;
@@ -0,0 +1,82 @@
1
+ /**
2
+ @file
3
+ @brief Returns the length of a numeric value
4
+ @details
5
+ Returns the length, in bytes, of a numeric value. If the value is
6
+ missing, then 0 is returned.
7
+
8
+ The function itself takes the following (positional) parameters:
9
+
10
+ | PARAMETER | DESCRIPTION |
11
+ |---|---|
12
+ | var | variable (or value) to be tested|
13
+
14
+ Usage:
15
+
16
+ %mcf_length(wrap=YES, insert_cmplib=YES)
17
+
18
+ data _null_;
19
+ ina=1;
20
+ inb=10000000;
21
+ inc=12345678;
22
+ ind=.;
23
+ outa=mcf_length(ina);
24
+ outb=mcf_length(inb);
25
+ outc=mcf_length(inc);
26
+ outd=mcf_length(ind);
27
+ put (out:)(=);
28
+ run;
29
+
30
+ Returns:
31
+
32
+ > outa=3 outb=4 outc=5 outd=0
33
+
34
+ @param [out] wrap= (NO) Choose YES to add the proc fcmp wrapper.
35
+ @param [out] insert_cmplib= (NO) Choose YES to insert the package into the
36
+ CMPLIB reference.
37
+ @param [out] lib= (work) The output library in which to create the catalog.
38
+ @param [out] cat= (sasjs) The output catalog in which to create the package.
39
+ @param [out] pkg= (utils) The output package in which to create the function.
40
+ Uses a 3 part format: libref.catalog.package
41
+
42
+ <h4> SAS Macros </h4>
43
+ @li mf_existfunction.sas
44
+
45
+ <h4> Related Macros </h4>
46
+ @li mcf_length.test.sas
47
+
48
+ **/
49
+
50
+ %macro mcf_length(wrap=NO
51
+ ,insert_cmplib=NO
52
+ ,lib=WORK
53
+ ,cat=SASJS
54
+ ,pkg=UTILS
55
+ )/*/STORE SOURCE*/;
56
+
57
+ %if %mf_existfunction(mcf_length)=1 %then %return;
58
+
59
+ %if &wrap=YES %then %do;
60
+ proc fcmp outlib=&lib..&cat..&pkg;
61
+ %end;
62
+
63
+ function mcf_length(var);
64
+ if var=. then len=0;
65
+ else if missing(var) or trunc(var,3)=var then len=3;
66
+ else if trunc(var,4)=var then len=4;
67
+ else if trunc(var,5)=var then len=5;
68
+ else if trunc(var,6)=var then len=6;
69
+ else if trunc(var,7)=var then len=7;
70
+ else len=8;
71
+ return(len);
72
+ endsub;
73
+
74
+ %if &wrap=YES %then %do;
75
+ quit;
76
+ %end;
77
+
78
+ %if &insert_cmplib=YES %then %do;
79
+ options insert=(CMPLIB=(&lib..&cat));
80
+ %end;
81
+
82
+ %mend mcf_length;
@@ -69,7 +69,7 @@
69
69
  %if %mf_existfunction(stpsrv_header)=1 %then %return;
70
70
 
71
71
  %if &wrap=YES %then %do;
72
- proc fcmp outcat=&lib..&cat..&pkg;
72
+ proc fcmp outlib=&lib..&cat..&pkg;
73
73
  %end;
74
74
 
75
75
  function stpsrv_header(name $, value $);
@@ -39,6 +39,9 @@
39
39
  @param [out] pkg= (utils) The output package in which to create the function.
40
40
  Uses a 3 part format: libref.catalog.package
41
41
 
42
+ <h4> SAS Macros </h4>
43
+ @li mf_existfunction.sas
44
+
42
45
  **/
43
46
 
44
47
  %macro mcf_string2file(wrap=NO
@@ -48,8 +51,10 @@
48
51
  ,pkg=UTILS
49
52
  )/*/STORE SOURCE*/;
50
53
 
54
+ %if %mf_existfunction(mcf_string2file)=1 %then %return;
55
+
51
56
  %if &wrap=YES %then %do;
52
- proc fcmp outcat=&lib..&cat..&pkg;
57
+ proc fcmp outlib=&lib..&cat..&pkg;
53
58
  %end;
54
59
 
55
60
  function mcf_string2file(filepath $, string $, mode $);
@@ -95,7 +95,6 @@ data _null_;
95
95
  put ' ';
96
96
  put '%macro mp_jsonout(action,ds,jref=_webout,dslabel=,fmt=Y ';
97
97
  put ' ,engine=DATASTEP ';
98
- put ' ,dbg=0 /* DEPRECATED */ ';
99
98
  put ' ,missing=NULL ';
100
99
  put ' ,showmeta=NO ';
101
100
  put ')/*/STORE SOURCE*/; ';
@@ -426,7 +425,7 @@ data _null_;
426
425
  put ' sysvlong=quote(trim(symget(''sysvlong''))); ';
427
426
  put ' put '',"SYSVLONG" : '' sysvlong; ';
428
427
  put ' put ",""SYSWARNINGTEXT"" : ""&syswarningtext"" "; ';
429
- put ' put '',"END_DTTM" : "'' "%sysfunc(datetime(),datetime20.3)" ''" ''; ';
428
+ put ' put '',"END_DTTM" : "'' "%sysfunc(datetime(),E8601DT26.6)" ''" ''; ';
430
429
  put ' length memsize $32; ';
431
430
  put ' memsize="%sysfunc(INPUTN(%sysfunc(getoption(memsize)), best.),sizekmg.)"; ';
432
431
  put ' memsize=quote(cats(memsize)); ';
@@ -13,9 +13,6 @@
13
13
  @param [in] stpcode= the source file (or fileref) containing the SAS code to load
14
14
  into the stp. For multiple files, they should simply be concatenated first.
15
15
  @param [in] minify= set to YES in order to strip comments, blank lines, and CRLFs.
16
-
17
- @param frefin= deprecated - a unique fileref is now always used
18
- @param frefout= deprecated - a unique fileref is now always used
19
16
  @param mDebug= set to 1 to show debug messages in the log
20
17
 
21
18
  @version 9.3
@@ -30,16 +27,8 @@
30
27
  ,stpcode=
31
28
  ,minify=NO
32
29
  ,mdebug=0
33
- /* deprecated */
34
- ,frefin=inmeta
35
- ,frefout=outmeta
36
30
  );
37
31
 
38
- %if &frefin ne inmeta or &frefout ne outmeta %then %do;
39
- %put %str(WARN)ING: the frefin and frefout parameters will be deprecated in
40
- an upcoming release.;
41
- %end;
42
-
43
32
  /* first, check if STP exists */
44
33
  %local tsuri;
45
34
  %let tsuri=stopifempty ;
@@ -165,7 +165,7 @@
165
165
  sysvlong=quote(trim(symget('sysvlong')));
166
166
  put ',"SYSVLONG" : ' sysvlong;
167
167
  put ",""SYSWARNINGTEXT"" : ""&syswarningtext"" ";
168
- put ',"END_DTTM" : "' "%sysfunc(datetime(),datetime20.3)" '" ';
168
+ put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
169
169
  length memsize $32;
170
170
  memsize="%sysfunc(INPUTN(%sysfunc(getoption(memsize)), best.),sizekmg.)";
171
171
  memsize=quote(cats(memsize));
package/package.json CHANGED
@@ -33,10 +33,7 @@
33
33
  "prepare": "git rev-parse --git-dir && git config core.hooksPath ./.git-hooks || true"
34
34
  },
35
35
  "devDependencies": {
36
- "@sasjs/cli": "^3.4.1"
36
+ "@sasjs/cli": "3.6.0"
37
37
  },
38
- "dependencies": {
39
- "ts-loader": "^9.2.6"
40
- },
41
- "version": "3.10.0"
38
+ "version": "4.0.0"
42
39
  }
@@ -161,7 +161,7 @@
161
161
  sysvlong=quote(trim(symget('sysvlong')));
162
162
  put ',"SYSVLONG" : ' sysvlong;
163
163
  put ",""SYSWARNINGTEXT"" : ""&syswarningtext"" ";
164
- put ',"END_DTTM" : "' "%sysfunc(datetime(),datetime20.3)" '" ';
164
+ put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
165
165
  length autoexec $512;
166
166
  autoexec=quote(urlencode(trim(getoption('autoexec'))));
167
167
  put ',"AUTOEXEC" : ' autoexec;
@@ -239,7 +239,6 @@ data _null_;
239
239
  put ' ';
240
240
  put '%macro mp_jsonout(action,ds,jref=_webout,dslabel=,fmt=Y ';
241
241
  put ' ,engine=DATASTEP ';
242
- put ' ,dbg=0 /* DEPRECATED */ ';
243
242
  put ' ,missing=NULL ';
244
243
  put ' ,showmeta=NO ';
245
244
  put ')/*/STORE SOURCE*/; ';
@@ -627,7 +626,7 @@ data _null_;
627
626
  put ' sysvlong=quote(trim(symget(''sysvlong''))); ';
628
627
  put ' put '',"SYSVLONG" : '' sysvlong; ';
629
628
  put ' put ",""SYSWARNINGTEXT"" : ""&syswarningtext"" "; ';
630
- put ' put '',"END_DTTM" : "'' "%sysfunc(datetime(),datetime20.3)" ''" ''; ';
629
+ put ' put '',"END_DTTM" : "'' "%sysfunc(datetime(),E8601DT26.6)" ''" ''; ';
631
630
  put ' length memsize $32; ';
632
631
  put ' memsize="%sysfunc(INPUTN(%sysfunc(getoption(memsize)), best.),sizekmg.)"; ';
633
632
  put ' memsize=quote(cats(memsize)); ';
@@ -117,6 +117,7 @@ libname &libref1a JSON fileref=&fname1a;
117
117
  %let found=0;
118
118
  %put Getting object uri from &libref1a..items;
119
119
  data _null_;
120
+ length contenttype name $1000;
120
121
  set &libref1a..items;
121
122
  if contenttype="&contenttype" and upcase(name)="%upcase(&name)" then do;
122
123
  call symputx('uri',uri,'l');
@@ -114,6 +114,7 @@ libname &libref1a JSON fileref=&fname1a;
114
114
  %let found=0;
115
115
  %put Getting object uri from &libref1a..items;
116
116
  data _null_;
117
+ length contenttype name $1000;
117
118
  set &libref1a..items;
118
119
  if contenttype='jobDefinition' and upcase(name)="%upcase(&name)" then do;
119
120
  call symputx('uri',cats("&base_uri",uri),'l');
@@ -225,7 +225,7 @@
225
225
  sysvlong=quote(trim(symget('sysvlong')));
226
226
  put ',"SYSVLONG" : ' sysvlong;
227
227
  put ",""SYSWARNINGTEXT"" : ""&syswarningtext"" ";
228
- put ',"END_DTTM" : "' "%sysfunc(datetime(),datetime20.3)" '" ';
228
+ put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
229
229
  length memsize $32;
230
230
  memsize="%sysfunc(INPUTN(%sysfunc(getoption(memsize)), best.),sizekmg.)";
231
231
  memsize=quote(cats(memsize));
@@ -1,32 +0,0 @@
1
- /**
2
- @file mv_getaccesstoken.sas
3
- @brief deprecated - replaced by mv_tokenrefresh.sas
4
-
5
- @version VIYA V.03.04
6
- @author Allan Bowe, source: https://github.com/sasjs/core
7
-
8
- <h4> SAS Macros </h4>
9
- @li mv_tokenrefresh.sas
10
-
11
- **/
12
-
13
- %macro mv_getaccesstoken(client_id=someclient
14
- ,client_secret=somesecret
15
- ,grant_type=authorization_code
16
- ,code=
17
- ,user=
18
- ,pass=
19
- ,access_token_var=ACCESS_TOKEN
20
- ,refresh_token_var=REFRESH_TOKEN
21
- );
22
-
23
- %mv_tokenrefresh(client_id=&client_id
24
- ,client_secret=&client_secret
25
- ,grant_type=&grant_type
26
- ,user=&user
27
- ,pass=&pass
28
- ,access_token_var=&access_token_var
29
- ,refresh_token_var=&refresh_token_var
30
- )
31
-
32
- %mend mv_getaccesstoken;
@@ -1,23 +0,0 @@
1
- /**
2
- @file
3
- @brief deprecated - replaced by mv_registerclient.sas
4
-
5
- @version VIYA V.03.04
6
- @author Allan Bowe, source: https://github.com/sasjs/core
7
-
8
- <h4> SAS Macros </h4>
9
- @li mv_registerclient.sas
10
-
11
- **/
12
-
13
- %macro mv_getapptoken(client_id=someclient
14
- ,client_secret=somesecret
15
- ,grant_type=authorization_code
16
- );
17
-
18
- %mv_registerclient(client_id=&client_id
19
- ,client_secret=&client_secret
20
- ,grant_type=&grant_type
21
- )
22
-
23
- %mend mv_getapptoken;
@@ -1,33 +0,0 @@
1
- /**
2
- @file mv_getrefreshtoken.sas
3
- @brief deprecated - replaced by mv_tokenauth.sas
4
-
5
- @version VIYA V.03.04
6
- @author Allan Bowe, source: https://github.com/sasjs/core
7
-
8
- <h4> SAS Macros </h4>
9
- @li mv_tokenauth.sas
10
-
11
- **/
12
-
13
- %macro mv_getrefreshtoken(client_id=someclient
14
- ,client_secret=somesecret
15
- ,grant_type=authorization_code
16
- ,code=
17
- ,user=
18
- ,pass=
19
- ,access_token_var=ACCESS_TOKEN
20
- ,refresh_token_var=REFRESH_TOKEN
21
- );
22
-
23
- %mv_tokenauth(client_id=&client_id
24
- ,client_secret=&client_secret
25
- ,grant_type=&grant_type
26
- ,code=&code
27
- ,user=&user
28
- ,pass=&pass
29
- ,access_token_var=&access_token_var
30
- ,refresh_token_var=&refresh_token_var
31
- )
32
-
33
- %mend mv_getrefreshtoken;