@sasjs/core 4.4.4 → 4.5.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
@@ -81,7 +81,7 @@ Macros used for interfacing with SAS Viya.
81
81
 
82
82
  Wait - this is a macro library - what is LUA doing here? Well, it is a little known fact that you CAN run LUA within a SAS Macro. It has to be written to a text file with a `.lua` extension, from where you can `%include` it. So, without using the `proc lua` wrapper.
83
83
 
84
- To contribute, simply write your freeform LUA in the LUA folder. Then run the `build.py`, which will convert your LUA into a data step with put statements, and create the macro wrapper with a `ml_` prefix. You can then use your module in any program by running:
84
+ To contribute, simply write your freeform LUA in the LUA folder. Then run the `build.py`, which will convert all files with a ".lua" extension into a macro wrapper with an `ml_` prefix (embedding the necessary data step put statements). You can then use your module in any program by running:
85
85
 
86
86
  ```sas
87
87
  /* compile the lua module */
@@ -95,8 +95,7 @@ endsubmit;
95
95
  run;
96
96
  ```
97
97
 
98
- - X command enabled
99
- - Prefixes: _mmw_,_mmu_,_mmx_
98
+ - Prefixes: _ml_
100
99
 
101
100
  ## Installation
102
101
 
@@ -129,11 +128,11 @@ filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
129
128
  - _mf_ for macro functions (can be used in open code).
130
129
  - _ml_ for macros that are used to compile LUA modules
131
130
  - _mm_ for metadata macros (interface with the metadata server).
132
- - _mmx_ for macros that use metadata and are XCMD enabled
131
+ - _mmx_ for macros that use metadata and are XCMD enabled (working on both windows and unix)
133
132
  - _mp_ for macro procedures (which generate sas code)
134
133
  - _ms_ for macro procedures that will only work with [@sasjs/server](https://github.com/sasjs/server)
135
134
  - _mv_ for macro procedures that will only work in Viya
136
- - _mx_ for macros that are XCMD enabled
135
+ - _mx_ for macros that are XCMD enabled (working on both windows and unix)
137
136
  - follow verb-noun convention
138
137
  - unix style line endings (lf)
139
138
  - individual lines should be no more than 80 characters long
@@ -193,11 +192,12 @@ When contributing to this library, it is therefore important to ensure that all
193
192
 
194
193
  ## Breaking Changes
195
194
 
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:
195
+ 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 (v5) becomes necessary:
197
196
 
198
197
  * mp_testservice.sas to be renamed as mp_execute.sas (as it doesn't actually test anything)
199
198
  * `insert_cmplib` option of mcf_xxx macros will be deprecated (the option is now checked automatically with value inserted only if needed)
200
- * mcf_xxx macros to have `wrap=` option defaulted to YES for convenience
199
+ * mcf_xxx macros to have `wrap=` option defaulted to YES for convenience. Set this option explicitly to avoid issues.
200
+ * mp_getddl.sas to be renamed to mp_ds2ddl.sas (consistent with other ds2xxx macros). A wrapper macro is already in place, and you are able to use this immediately. The default for SHOWLOG will also be YES instead of NO.
201
201
 
202
202
  ## Star Gazing
203
203
 
@@ -15,6 +15,7 @@
15
15
  @li /data
16
16
  @li /jobs
17
17
  @li /services
18
+ @li /tests
18
19
  @li /tests/jobs
19
20
  @li /tests/services
20
21
  @li /tests/macros
@@ -46,9 +47,13 @@
46
47
 
47
48
  /**
48
49
  * First check we are not in the tests/macros folder (which has no subfolders)
50
+ * or specifically in the testsetup or testteardown services
49
51
  */
50
- %if %index(&pgm,/tests/macros/) %then %do;
51
- %let root=%substr(&pgm,1,%index(&pgm,/tests/macros)-1);
52
+ %if %index(&pgm,/tests/macros/)
53
+ or %index(&pgm,/tests/testsetup)
54
+ or %index(&pgm,/tests/testteardown)
55
+ %then %do;
56
+ %let root=%substr(&pgm,1,%index(&pgm,/tests)-1);
52
57
  &root
53
58
  %return;
54
59
  %end;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  @file
3
- @brief Checks if a set of macro variables exist / contain values.
3
+ @brief Checks if a set of macro variables exist AND contain values.
4
4
  @details Writes ERROR to log if abortType is SOFT, else will call %mf_abort.
5
5
  Usage:
6
6
 
@@ -14,10 +14,11 @@
14
14
  <h4> SAS Macros </h4>
15
15
  @li mf_abort.sas
16
16
 
17
- @param verifyvars space separated list of macro variable names
18
- @param makeupcase= set to YES to convert all variable VALUES to
17
+ @param [in] verifyvars Space separated list of macro variable names
18
+ @param [in] makeupcase= (NO) Set to YES to convert all variable VALUES to
19
19
  uppercase.
20
- @param mAbort= Abort Type. Default is SOFT (writes err to log).
20
+ @param [in] mAbort= (SOFT) Abort Type. When SOFT, simply writes an err
21
+ message to the log.
21
22
  Set to any other value to call mf_abort (which can be configured to abort in
22
23
  various fashions according to context).
23
24
 
@@ -58,8 +59,14 @@
58
59
 
59
60
  %goto exit_success;
60
61
  %exit_err:
61
- %if &mAbort=SOFT %then %put %str(ERR)OR: &abortmsg;
62
- %else %mf_abort(mac=mf_verifymacvars,type=&mabort,msg=&abortmsg);
62
+ %put %str(ERR)OR: &abortmsg;
63
+ %mf_abort(iftrue=(&mabort ne SOFT),
64
+ mac=mf_verifymacvars,
65
+ msg=%str(&abortmsg)
66
+ )
67
+ 0
68
+ %return;
63
69
  %exit_success:
70
+ 1
64
71
 
65
72
  %mend mf_verifymacvars;
@@ -5,6 +5,12 @@
5
5
  make use of permanent tables. To avoid duplication in definitions, this
6
6
  macro provides a central location for managing the corresponding DDL.
7
7
 
8
+ Note - this macro is likely to be deprecated in future in favour of a
9
+ dedicated "datamodel" folder (prefix mddl)
10
+
11
+ Any corresponding data would go in a seperate repo, to avoid this one
12
+ ballooning in size!
13
+
8
14
  Example usage:
9
15
 
10
16
  %mp_coretable(LOCKTABLE,libds=work.locktable)
@@ -0,0 +1,30 @@
1
+ /**
2
+ @file
3
+ @brief A wrapper for mp_getddl.sas
4
+ @details In the next release, this will be the main version.
5
+
6
+
7
+ <h4> SAS Macros </h4>
8
+ @li mp_getddl.sas
9
+
10
+ **/
11
+
12
+ %macro mp_ds2ddl(libds,fref=getddl,flavour=SAS,showlog=YES,schema=
13
+ ,applydttm=NO
14
+ )/*/STORE SOURCE*/;
15
+
16
+ %local libref;
17
+ %let libds=%upcase(&libds);
18
+ %let libref=%scan(&libds,1,.);
19
+ %if &libref=&libds %then %let libds=WORK.&libds;
20
+
21
+ %mp_getddl(%scan(&libds,1,.)
22
+ ,%scan(&libds,2,.)
23
+ ,fref=&fref
24
+ ,flavour=SAS
25
+ ,showlog=&showlog
26
+ ,schema=&schema
27
+ ,applydttm=&applydttm
28
+ )
29
+
30
+ %mend mp_ds2ddl;
@@ -6,7 +6,8 @@
6
6
  SYSCC to 1008 if bad records are found, and call mp_abort.sas for a
7
7
  graceful service exit (configurable).
8
8
 
9
- Used for dynamic filtering in [Data Controller for SAS&reg;](https://datacontroller.io).
9
+ Used for dynamic filtering in [Data Controller for SAS&reg;](
10
+ https://datacontroller.io).
10
11
 
11
12
  Usage:
12
13
 
@@ -125,7 +126,7 @@ data &outds;
125
126
  output;
126
127
  end;
127
128
  if OPERATOR_NM not in
128
- ('=','>','<','<=','>=','BETWEEN','IN','NOT IN','NE','CONTAINS')
129
+ ('=','>','<','<=','>=','BETWEEN','IN','NOT IN','NE','CONTAINS','GE','LE')
129
130
  then do;
130
131
  REASON_CD='Invalid OPERATOR_NM: '!!cats(OPERATOR_NM);
131
132
  putlog REASON_CD= OPERATOR_NM=;
@@ -8,8 +8,13 @@
8
8
  https://sasapps.io)). This macro is also used in [Data Controller for SAS](
9
9
  https://datacontroller.io).
10
10
 
11
+ A more recent feature of this macro is the ability to support filter queries
12
+ on Format Catalogs. This is achieved by adding a `-FC` suffix to the `libds`
13
+ parameter - where the "ds" in this case is the catalog name.
11
14
 
12
- @param [in] libds= The target dataset to be filtered (lib should be assigned)
15
+
16
+ @param [in] libds= The target dataset to be filtered (lib should be assigned).
17
+ If filtering a format catalog, add the following suffix: `-FC`.
13
18
  @param [in] queryds= (WORK.FILTERQUERY) The temporary input query dataset to
14
19
  be validated. Has the following format:
15
20
  |GROUP_LOGIC:$3|SUBGROUP_LOGIC:$3|SUBGROUP_ID:8.|VARIABLE_NM:$32|OPERATOR_NM:$10|RAW_VALUE:$32767|
@@ -78,7 +83,10 @@
78
83
  %put &sysmacroname entry vars:;
79
84
  %put _local_;
80
85
 
81
- %local ds1 ds2 ds3 ds4 filter_hash;
86
+ %local ds0 ds1 ds2 ds3 ds4 filter_hash orig_libds;
87
+ %let libds=%upcase(&libds);
88
+ %let orig_libds=&libds;
89
+
82
90
  %mp_abort(iftrue= (&syscc ne 0)
83
91
  ,mac=mp_filterstore
84
92
  ,msg=%str(syscc=&syscc on macro entry)
@@ -96,12 +104,49 @@
96
104
  ,msg=%str(Invalid lock_table value: &lock_table)
97
105
  )
98
106
 
99
- /* validate query */
107
+ /**
108
+ * validate query
109
+ * use format catalog export, if a format
110
+ */
111
+ %if "%substr(&libds,%length(&libds)-2,3)"="-FC" %then %do;
112
+ %let libds=%scan(&libds,1,-); /* chop off -FC extension */
113
+ %let ds0=%mf_getuniquename(prefix=fmtds_);
114
+ /*
115
+ There is no need to export the entire format catalog here - the validations
116
+ are done against the data model, not the data values. So we can simply
117
+ hardcode the structure based on the cntlout dataset.
118
+ */
119
+ proc sql;
120
+ create table &ds0(
121
+ FMTNAME char(32)
122
+ ,START char(16)
123
+ ,END char(16)
124
+ ,LABEL char(256)
125
+ ,MIN num length=3
126
+ ,MAX num length=3
127
+ ,DEFAULT num length=3
128
+ ,LENGTH num length=3
129
+ ,FUZZ num
130
+ ,PREFIX char(2)
131
+ ,MULT num
132
+ ,FILL char(1)
133
+ ,NOEDIT num length=3
134
+ ,TYPE char(1)
135
+ ,SEXCL char(1)
136
+ ,EEXCL char(1)
137
+ ,HLO char(13)
138
+ ,DECSEP char(1)
139
+ ,DIG3SEP char(1)
140
+ ,DATATYPE char(8)
141
+ ,LANGUAGE char(8)
142
+ );
143
+ %let libds=&ds0;
144
+ %end;
100
145
  %mp_filtercheck(&queryds,targetds=&libds,abort=YES)
101
146
 
102
147
  /* hash the result */
103
148
  %let ds1=%mf_getuniquename(prefix=hashds);
104
- %mp_hashdataset(&queryds,outds=&ds1,salt=&libds)
149
+ %mp_hashdataset(&queryds,outds=&ds1,salt=&orig_libds)
105
150
  %let filter_hash=%upcase(%mf_getvalue(&ds1,hashkey));
106
151
  %if &mdebug=1 %then %do;
107
152
  data _null_;
@@ -132,7 +177,7 @@ run;
132
177
  %let ds3=%mf_getuniquename(prefix=filtersum);
133
178
  data work.&ds3;
134
179
  if 0 then set &filter_summary;
135
- filter_table=symget('libds');
180
+ filter_table="&orig_libds";
136
181
  filter_hash="&filter_hash";
137
182
  PROCESSED_DTTM=%sysfunc(datetime());
138
183
  output;
@@ -134,6 +134,10 @@ create table &outsummary as
134
134
  proc format library=&&fmtloc&i CNTLOUT=&tempds;
135
135
  select &&fmtname&i;
136
136
  run;
137
+ data &tempds;
138
+ length label $256;
139
+ set &tempds;
140
+ run;
137
141
  proc append base=&outdetail data=&tempds;
138
142
  run;
139
143
  %end;
@@ -59,7 +59,10 @@
59
59
  %&mD.put Executing &sysmacroname..sas;
60
60
  %&mD.put _local_;
61
61
 
62
- %mf_verifymacvars(tree name)
62
+ %mp_abort(iftrue= (%mf_verifymacvars(tree name)=0)
63
+ ,mac=&sysmacroname
64
+ ,msg=%str(Empty inputs: tree name)
65
+ )
63
66
 
64
67
  /**
65
68
  * check tree exists
@@ -47,7 +47,10 @@
47
47
  %&mD.put Executing &sysmacroname..sas;
48
48
  %&mD.put _local_;
49
49
 
50
- %mf_verifymacvars(tree name)
50
+ %mp_abort(iftrue= (%mf_verifymacvars(tree name)=0)
51
+ ,mac=&sysmacroname
52
+ ,msg=%str(Empty inputs: tree name)
53
+ )
51
54
 
52
55
  /**
53
56
  * check tree exists
@@ -133,12 +133,14 @@ run;
133
133
  filename &frefin temp;
134
134
  filename &frefout temp;
135
135
 
136
- %if &engine=BASE %then %do;
137
-
138
- %mf_verifymacvars(libname libref engine servercontext tree)
139
-
140
-
136
+ %mp_abort(iftrue= (
137
+ &engine=BASE & %mf_verifymacvars(libname libref engine servercontext tree)=0
138
+ )
139
+ ,mac=&sysmacroname
140
+ ,msg=%str(Empty inputs: libname libref engine servercontext tree)
141
+ )
141
142
 
143
+ %if &engine=BASE %then %do;
142
144
  /**
143
145
  * Check that the ServerContext exists
144
146
  */
@@ -108,7 +108,12 @@
108
108
  %&mD.put Executing mm_CreateSTP.sas;
109
109
  %&mD.put _local_;
110
110
 
111
- %mf_verifymacvars(stpname filename directory tree)
111
+ %mp_abort(
112
+ iftrue=(%mf_verifymacvars(stpname filename directory tree)=0)
113
+ ,mac=&sysmacroname
114
+ ,msg=%str(Empty inputs: stpname filename directory tree)
115
+ )
116
+
112
117
  %mp_dropmembers(%scan(&outds,2,.))
113
118
 
114
119
  /**
package/package.json CHANGED
@@ -33,7 +33,8 @@
33
33
  "prepare": "git rev-parse --git-dir && git config core.hooksPath ./.git-hooks || true"
34
34
  },
35
35
  "devDependencies": {
36
- "@sasjs/cli": "3.6.0"
36
+ "@sasjs/cli": "3.6.0",
37
+ "@sasjs/core": "4.4.7"
37
38
  },
38
- "version": "4.4.4"
39
+ "version": "4.5.0"
39
40
  }