@sasjs/core 4.4.7 → 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 +3 -2
- package/base/mp_coretable.sas +6 -0
- package/base/mp_ds2ddl.sas +30 -0
- package/base/mp_filtercheck.sas +3 -2
- package/base/mp_filterstore.sas +50 -5
- package/base/mp_getformats.sas +4 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -192,11 +192,12 @@ When contributing to this library, it is therefore important to ensure that all
|
|
|
192
192
|
|
|
193
193
|
## Breaking Changes
|
|
194
194
|
|
|
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 (
|
|
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:
|
|
196
196
|
|
|
197
197
|
* mp_testservice.sas to be renamed as mp_execute.sas (as it doesn't actually test anything)
|
|
198
198
|
* `insert_cmplib` option of mcf_xxx macros will be deprecated (the option is now checked automatically with value inserted only if needed)
|
|
199
|
-
* 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.
|
|
200
201
|
|
|
201
202
|
## Star Gazing
|
|
202
203
|
|
package/base/mp_coretable.sas
CHANGED
|
@@ -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;
|
package/base/mp_filtercheck.sas
CHANGED
|
@@ -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®](
|
|
9
|
+
Used for dynamic filtering in [Data Controller for SAS®](
|
|
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=;
|
package/base/mp_filterstore.sas
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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=&
|
|
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=
|
|
180
|
+
filter_table="&orig_libds";
|
|
136
181
|
filter_hash="&filter_hash";
|
|
137
182
|
PROCESSED_DTTM=%sysfunc(datetime());
|
|
138
183
|
output;
|
package/base/mp_getformats.sas
CHANGED