@sasjs/core 4.18.4 → 4.18.7
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_assertscope.sas +1 -1
- package/base/mp_hashdataset.sas +46 -43
- package/package.json +1 -1
- package/server/ms_getfile.sas +11 -2
- package/server/ms_webout.sas +1 -0
package/base/mp_assertscope.sas
CHANGED
package/base/mp_hashdataset.sas
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
@file
|
|
3
3
|
@brief Returns a unique hash for a dataset
|
|
4
|
-
@details Ignores metadata attributes, used only to hash values.
|
|
5
|
-
datasets must
|
|
4
|
+
@details Ignores metadata attributes, used only to hash values. If used to
|
|
5
|
+
compare datasets, they must have their columns and rows in the same order.
|
|
6
6
|
|
|
7
7
|
%mp_hashdataset(sashelp.class,outds=myhash)
|
|
8
8
|
|
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
@li mf_getattrn.sas
|
|
18
18
|
@li mf_getuniquename.sas
|
|
19
19
|
@li mf_getvarlist.sas
|
|
20
|
-
@li
|
|
20
|
+
@li mp_md5.sas
|
|
21
|
+
|
|
22
|
+
<h4> Related Files </h4>
|
|
23
|
+
@li mp_hashdataset.test.sas
|
|
21
24
|
|
|
22
25
|
@param [in] libds dataset to hash
|
|
23
26
|
@param [in] salt= Provide a salt (could be, for instance, the dataset name)
|
|
@@ -35,48 +38,48 @@
|
|
|
35
38
|
|
|
36
39
|
%macro mp_hashdataset(
|
|
37
40
|
libds,
|
|
38
|
-
outds
|
|
41
|
+
outds=work._data_,
|
|
39
42
|
salt=,
|
|
40
43
|
iftrue=%str(1=1)
|
|
41
44
|
)/*/STORE SOURCE*/;
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
%local keyvar /* roll up the md5 */
|
|
47
|
+
prevkeyvar /* retain prev record md5 */
|
|
48
|
+
lastvar /* last var in input ds */
|
|
49
|
+
cvars nvars;
|
|
50
|
+
|
|
51
|
+
%if not(%eval(%unquote(&iftrue))) %then %return;
|
|
52
|
+
|
|
53
|
+
/* avoid naming conflict for hash key vars */
|
|
54
|
+
%let keyvar=%mf_getuniquename();
|
|
55
|
+
%let prevkeyvar=%mf_getuniquename();
|
|
56
|
+
%let lastvar=%mf_getuniquename();
|
|
44
57
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
&
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
%else %do;
|
|
74
|
-
!!put(md5(trim(put(&var*1,binary64.))),$hex32.)
|
|
75
|
-
%end;
|
|
76
|
-
%end;
|
|
77
|
-
),$hex32.);
|
|
78
|
-
&prevkeyvar=&keyvar;
|
|
79
|
-
if &lastvar then output;
|
|
80
|
-
run;
|
|
81
|
-
%end;
|
|
82
|
-
%mend mp_hashdataset;
|
|
58
|
+
%if %mf_getattrn(&libds,NLOBS)=0 %then %do;
|
|
59
|
+
data &outds;
|
|
60
|
+
length hashkey $32;
|
|
61
|
+
retain hashkey "%sysfunc(md5(%str(&salt)),$hex32.)";
|
|
62
|
+
output;
|
|
63
|
+
stop;
|
|
64
|
+
run;
|
|
65
|
+
%put &sysmacroname: Dataset &libds is empty, or is not a dataset;
|
|
66
|
+
%put &sysmacroname: hashkey of &outds is based on salt (&salt) only;
|
|
67
|
+
%end;
|
|
68
|
+
%else %if %mf_getattrn(&libds,NLOBS)<0 %then %do;
|
|
69
|
+
%put %str(ERR)OR: Dataset &libds is not a dataset;
|
|
70
|
+
%end;
|
|
71
|
+
%else %do;
|
|
72
|
+
data &outds(rename=(&keyvar=hashkey) keep=&keyvar)/nonote2err;
|
|
73
|
+
length &prevkeyvar &keyvar $32;
|
|
74
|
+
retain &prevkeyvar "%sysfunc(md5(%str(&salt)),$hex32.)";
|
|
75
|
+
set &libds end=&lastvar;
|
|
76
|
+
/* hash should include previous row */
|
|
77
|
+
&keyvar=%mp_md5(
|
|
78
|
+
cvars=%mf_getvarlist(&libds,typefilter=C) &prevkeyvar,
|
|
79
|
+
nvars=%mf_getvarlist(&libds,typefilter=N)
|
|
80
|
+
);
|
|
81
|
+
&prevkeyvar=&keyvar;
|
|
82
|
+
if &lastvar then output;
|
|
83
|
+
run;
|
|
84
|
+
%end;
|
|
85
|
+
%mend mp_hashdataset;
|
package/package.json
CHANGED
package/server/ms_getfile.sas
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
@param [out] outref= (msgetfil) The fileref to contain the file.
|
|
12
12
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
|
13
13
|
|
|
14
|
+
<h4> SAS Macros </h4>
|
|
15
|
+
@li mf_getuniquefileref.sas
|
|
16
|
+
@li mf_getuniquename.sas
|
|
14
17
|
|
|
15
18
|
**/
|
|
16
19
|
|
|
@@ -19,14 +22,20 @@
|
|
|
19
22
|
,mdebug=0
|
|
20
23
|
);
|
|
21
24
|
|
|
22
|
-
|
|
25
|
+
/* use the recfm in a separate fileref to avoid issues with subsequent reads */
|
|
26
|
+
%local binaryfref floc;
|
|
27
|
+
%let binaryfref=%mf_getuniquefileref();
|
|
28
|
+
%let floc=%sysfunc(pathname(work))/%mf_getuniquename().txt;
|
|
29
|
+
filename &outref "&floc";
|
|
30
|
+
filename &binaryfref "&floc" recfm=n;
|
|
23
31
|
|
|
24
|
-
proc http method='GET' out=&
|
|
32
|
+
proc http method='GET' out=&binaryfref
|
|
25
33
|
url="&_sasjs_apiserverurl/SASjsApi/drive/file?_filePath=&driveloc";
|
|
26
34
|
%if &mdebug=1 %then %do;
|
|
27
35
|
debug level=2;
|
|
28
36
|
%end;
|
|
29
37
|
run;
|
|
30
38
|
|
|
39
|
+
filename &binaryfref clear;
|
|
31
40
|
|
|
32
41
|
%mend ms_getfile;
|