@sasjs/core 4.67.2 → 4.68.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/base/mp_assert.sas +1 -1
- package/base/mp_assertcols.sas +1 -1
- package/base/mp_assertcolvals.sas +1 -1
- package/base/mp_assertdsobs.sas +1 -1
- package/base/mp_assertscope.sas +1 -1
- package/base/mp_ds2csv.sas +2 -2
- package/base/mp_hashdataset.sas +7 -7
- package/base/mp_init.sas +1 -0
- package/base/mp_loadformat.sas +13 -4
- package/base/mp_md5.sas +5 -0
- package/base/mp_rowhash.sas +90 -0
- package/package.json +1 -1
package/base/mp_assert.sas
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
)/*/STORE SOURCE*/;
|
|
36
36
|
|
|
37
37
|
data ;
|
|
38
|
-
length
|
|
38
|
+
length test_result $4 test_description $256 test_comments $256;
|
|
39
39
|
test_description=symget('desc');
|
|
40
40
|
test_comments="&sysmacroname: Test result of "!!symget('iftrue');
|
|
41
41
|
%if %eval(%unquote(&iftrue)) %then %do;
|
package/base/mp_assertcols.sas
CHANGED
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
%end;
|
|
109
109
|
|
|
110
110
|
data;
|
|
111
|
-
length
|
|
111
|
+
length test_result $4 test_description $256 test_comments $256;
|
|
112
112
|
test_description=symget('desc');
|
|
113
113
|
if test_description='0'
|
|
114
114
|
then test_description="Testing &inds for existence of &test of: &cols";
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
)
|
|
144
144
|
|
|
145
145
|
data;
|
|
146
|
-
length
|
|
146
|
+
length test_result $4 test_description $256 test_comments $256;
|
|
147
147
|
test_description=symget('desc');
|
|
148
148
|
test_result='FAIL';
|
|
149
149
|
test_comments="&sysmacroname: &lib..&ds..&col has &result/&orig values "
|
package/base/mp_assertdsobs.sas
CHANGED
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
%end;
|
|
88
88
|
|
|
89
89
|
data &ds;
|
|
90
|
-
length
|
|
90
|
+
length test_result $4 test_description $256 test_comments $256;
|
|
91
91
|
test_description=symget('desc');
|
|
92
92
|
test_result='FAIL';
|
|
93
93
|
test_comments="&sysmacroname: Dataset &inds has &nobs observations.";
|
package/base/mp_assertscope.sas
CHANGED
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
%end;
|
|
132
132
|
|
|
133
133
|
data ;
|
|
134
|
-
length
|
|
134
|
+
length test_result $4 test_description $256 test_comments $256;
|
|
135
135
|
test_description=symget('desc');
|
|
136
136
|
test_comments=symget('test_comments');
|
|
137
137
|
test_result=symget('test_result');
|
package/base/mp_ds2csv.sas
CHANGED
|
@@ -130,10 +130,10 @@ data _null_;
|
|
|
130
130
|
* there is not much point importing a short length numeric like this,
|
|
131
131
|
* eg with best4., as the resulting variable will still be stored as
|
|
132
132
|
* length 8. We need a length or format statement to ensure variable
|
|
133
|
-
* is
|
|
133
|
+
* is created with the smaller length...
|
|
134
134
|
**/
|
|
135
135
|
else if vlen<8 then header=cats(varnm,':best',vlen,'.');
|
|
136
|
-
else header=cats(varnm,':
|
|
136
|
+
else header=cats(varnm,':best32.');
|
|
137
137
|
end;
|
|
138
138
|
%end;
|
|
139
139
|
%else %do;
|
package/base/mp_hashdataset.sas
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
@li mf_getattrn.sas
|
|
18
18
|
@li mf_getuniquename.sas
|
|
19
19
|
@li mf_getvarlist.sas
|
|
20
|
-
@li
|
|
20
|
+
@li mp_rowhash.sas
|
|
21
21
|
|
|
22
22
|
<h4> Related Files </h4>
|
|
23
23
|
@li mp_hashdataset.test.sas
|
|
@@ -46,8 +46,7 @@
|
|
|
46
46
|
|
|
47
47
|
%local keyvar /* roll up the md5 */
|
|
48
48
|
prevkeyvar /* retain prev record md5 */
|
|
49
|
-
lastvar /* last var in input ds
|
|
50
|
-
cvars nvars;
|
|
49
|
+
lastvar /* last var in input ds */;
|
|
51
50
|
|
|
52
51
|
%if not(%eval(%unquote(&iftrue))) %then %return;
|
|
53
52
|
|
|
@@ -79,10 +78,11 @@
|
|
|
79
78
|
retain &prevkeyvar;
|
|
80
79
|
if _n_=1 then &prevkeyvar=put(md5("&salt"),$hex32.);
|
|
81
80
|
set &libds end=&lastvar;
|
|
82
|
-
/* hash should include previous row */
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
/* hash should include previous row - listed first so it is hashed first */
|
|
82
|
+
%mp_rowhash(
|
|
83
|
+
md5_col=&keyvar
|
|
84
|
+
,cvars=&prevkeyvar %mf_getvarlist(&libds,typefilter=C)
|
|
85
|
+
,nvars=%mf_getvarlist(&libds,typefilter=N)
|
|
86
86
|
);
|
|
87
87
|
&prevkeyvar=&keyvar;
|
|
88
88
|
if &lastvar then output;
|
package/base/mp_init.sas
CHANGED
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
|
|
38
38
|
%global
|
|
39
39
|
SASJS_PREFIX /* the ONLY hard-coded global macro variable in SASjs */
|
|
40
|
+
&prefix.PROCESSMODE &prefix._STPSRV_HEADER_LOC /* SASjs server specific vars*/
|
|
40
41
|
&prefix._FUNCTIONS /* used in mcf_init() to track core function compilation */
|
|
41
42
|
&prefix._INIT_NUM /* initialisation time as numeric */
|
|
42
43
|
&prefix._INIT_DTTM /* initialisation time in E8601DT26.6 format */
|
package/base/mp_loadformat.sas
CHANGED
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
@li mp_aligndecimal.sas
|
|
46
46
|
@li mp_cntlout.sas
|
|
47
47
|
@li mp_lockanytable.sas
|
|
48
|
-
@li
|
|
48
|
+
@li mp_rowhash.sas
|
|
49
49
|
@li mp_storediffs.sas
|
|
50
50
|
|
|
51
51
|
<h4> Related Macros </h4>
|
|
@@ -174,14 +174,19 @@ select distinct
|
|
|
174
174
|
%let nvars=FMTROW MIN MAX DEFAULT LENGTH FUZZ MULT NOEDIT;
|
|
175
175
|
data &base_fmts/note2err;
|
|
176
176
|
set &base_fmts;
|
|
177
|
-
fmthash
|
|
177
|
+
length fmthash $32;
|
|
178
|
+
%mp_rowhash(
|
|
179
|
+
md5_col=fmthash
|
|
180
|
+
,cvars=&cvars
|
|
181
|
+
,nvars=&nvars
|
|
182
|
+
)
|
|
178
183
|
run;
|
|
179
184
|
|
|
180
185
|
/**
|
|
181
186
|
* Ensure input table and base_formats have consistent lengths and types
|
|
182
187
|
*/
|
|
183
188
|
data &inlibds/nonote2err;
|
|
184
|
-
length &delete_col $3 FMTROW 8 start end label $32767;
|
|
189
|
+
length &delete_col $3 FMTROW 8 start end label $32767 fmthash $32;
|
|
185
190
|
if 0 then set &base_fmts;
|
|
186
191
|
set &libds;
|
|
187
192
|
by type fmtname notsorted;
|
|
@@ -203,7 +208,11 @@ data &inlibds/nonote2err;
|
|
|
203
208
|
%mp_aligndecimal(end,width=16)
|
|
204
209
|
end;
|
|
205
210
|
|
|
206
|
-
|
|
211
|
+
%mp_rowhash(
|
|
212
|
+
md5_col=fmthash
|
|
213
|
+
,cvars=&cvars
|
|
214
|
+
,nvars=&nvars
|
|
215
|
+
)
|
|
207
216
|
run;
|
|
208
217
|
|
|
209
218
|
/**
|
package/base/mp_md5.sas
CHANGED
|
@@ -28,11 +28,16 @@
|
|
|
28
28
|
@li Global option: `options dsoptions=nonote2err;`
|
|
29
29
|
@li Data step option: `data YOURLIB.YOURDATASET /nonote2err;`
|
|
30
30
|
|
|
31
|
+
For very wide tables (hundreds or thousands of columns) consider using
|
|
32
|
+
`mp_rowhash.sas`, which builds the same type of row hash iteratively and
|
|
33
|
+
avoids creating a single, very long concatenated SAS expression.
|
|
34
|
+
|
|
31
35
|
@param [in] cvars= () Space seperated list of character variables
|
|
32
36
|
@param [in] nvars= () Space seperated list of numeric variables
|
|
33
37
|
|
|
34
38
|
<h4> Related Programs </h4>
|
|
35
39
|
@li mp_init.sas
|
|
40
|
+
@li mp_rowhash.sas
|
|
36
41
|
|
|
37
42
|
@version 9.2
|
|
38
43
|
@author Allan Bowe
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@file
|
|
3
|
+
@brief Iterative row-level MD5 hash generator
|
|
4
|
+
@details Generates DATA step statements that compute a deterministic,
|
|
5
|
+
row-level MD5 hash using a Merkle-style construction. Each variable is
|
|
6
|
+
hashed independently and the resulting raw 16-byte digests are combined
|
|
7
|
+
iteratively. This avoids concatenating the per-variable hex digests into a
|
|
8
|
+
single SAS character expression, which overflows when datasets contain many
|
|
9
|
+
variables.
|
|
10
|
+
|
|
11
|
+
Temporary variables use five leading underscores.
|
|
12
|
+
|
|
13
|
+
This macro is called from inside a DATA step. The caller is responsible
|
|
14
|
+
for declaring the output hash column if it does not already exist on the
|
|
15
|
+
input dataset.
|
|
16
|
+
|
|
17
|
+
Variables are hashed in the order supplied. If a particular variable
|
|
18
|
+
needs to influence the hash first (for example the previous row hash in
|
|
19
|
+
`mp_hashdataset`, or business dates in Data Controller's bitemporal
|
|
20
|
+
loader) simply list it first in `cvars` or `nvars`.
|
|
21
|
+
|
|
22
|
+
@param [in] md5_col= Name of the output hash column.
|
|
23
|
+
@param [in] cvars= Space separated list of character variables to hash.
|
|
24
|
+
@param [in] nvars= Space separated list of numeric variables to hash.
|
|
25
|
+
|
|
26
|
+
@version 9.3M5
|
|
27
|
+
@author Allan Bowe
|
|
28
|
+
**/
|
|
29
|
+
|
|
30
|
+
%macro mp_rowhash(
|
|
31
|
+
md5_col=
|
|
32
|
+
,cvars=
|
|
33
|
+
,nvars=
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
/* DATA step temp variables use five leading underscores. The names
|
|
37
|
+
are generated at macro invocation to avoid clashing with data columns. */
|
|
38
|
+
%local state digest pair numtext normal i chars nums;
|
|
39
|
+
%let state=%mf_getuniquename(prefix=_____state_);
|
|
40
|
+
%let digest=%mf_getuniquename(prefix=_____digest_);
|
|
41
|
+
%let pair=%mf_getuniquename(prefix=_____pair_);
|
|
42
|
+
%let numtext=%mf_getuniquename(prefix=_____numtext_);
|
|
43
|
+
%let normal=%mf_getuniquename(prefix=_____normal_);
|
|
44
|
+
%let i=%mf_getuniquename(prefix=_____i_);
|
|
45
|
+
%let chars=%mf_getuniquename(prefix=_____chars_);
|
|
46
|
+
%let nums=%mf_getuniquename(prefix=_____nums_);
|
|
47
|
+
|
|
48
|
+
length &state $16
|
|
49
|
+
&digest $16
|
|
50
|
+
&pair $32
|
|
51
|
+
&numtext $64
|
|
52
|
+
&normal &i 8;
|
|
53
|
+
if _n_=1 then call missing(&state,&digest,&pair,&numtext,&normal,&i);
|
|
54
|
+
drop &state &digest &pair &numtext &normal &i;
|
|
55
|
+
|
|
56
|
+
/* Versioned seed prevents confusion with other hashing schemes. */
|
|
57
|
+
&state = md5('DC HASH v2');
|
|
58
|
+
|
|
59
|
+
%if %length(&cvars)>0 %then %do;
|
|
60
|
+
array &chars{*} $ &cvars;
|
|
61
|
+
do &i = 1 to dim(&chars);
|
|
62
|
+
/* Leading blanks are retained. */
|
|
63
|
+
&digest = md5(trimn(&chars[&i]));
|
|
64
|
+
substr(&pair, 1, 16) = &state;
|
|
65
|
+
substr(&pair, 17, 16) = &digest;
|
|
66
|
+
&state = md5(&pair);
|
|
67
|
+
end;
|
|
68
|
+
%end;
|
|
69
|
+
|
|
70
|
+
%if %length(&nvars)>0 %then %do;
|
|
71
|
+
array &nums{*} &nvars;
|
|
72
|
+
do &i = 1 to dim(&nums);
|
|
73
|
+
/*
|
|
74
|
+
multiply-by-one for consistent cross-system precision.
|
|
75
|
+
Ignore null to protect SAS special missing values.
|
|
76
|
+
Cannot use IFN() as it evaluates both sides
|
|
77
|
+
*/
|
|
78
|
+
if missing(&nums[&i]) then &normal = &nums[&i];
|
|
79
|
+
else &normal = &nums[&i] * 1;
|
|
80
|
+
&numtext = put(&normal, binary64.);
|
|
81
|
+
&digest = md5(trim(&numtext));
|
|
82
|
+
substr(&pair, 1, 16) = &state;
|
|
83
|
+
substr(&pair, 17, 16) = &digest;
|
|
84
|
+
&state = md5(&pair);
|
|
85
|
+
end;
|
|
86
|
+
%end;
|
|
87
|
+
|
|
88
|
+
&md5_col = put(&state, $hex32.);
|
|
89
|
+
|
|
90
|
+
%mend mp_rowhash;
|
package/package.json
CHANGED