@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.
@@ -106,7 +106,7 @@
106
106
 
107
107
  proc compare
108
108
  base=&scopeds(where=(upcase(name) not in (%mf_getquotedstr(&ilist))))
109
- compare=&ds;
109
+ compare=&ds noprint;
110
110
  run;
111
111
 
112
112
  %if &sysinfo=0 %then %do;
@@ -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. Compared
5
- datasets must be in the same order.
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 mf_getvartype.sas
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
- %if not(%eval(%unquote(&iftrue))) %then %return;
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
- %if %mf_getattrn(&libds,NLOBS)=0 %then %do;
46
- %put %str(WARN)ING: Dataset &libds is empty, or is not a dataset;
47
- %end;
48
- %else %if %mf_getattrn(&libds,NLOBS)<0 %then %do;
49
- %put %str(ERR)OR: Dataset &libds is not a dataset;
50
- %end;
51
- %else %do;
52
- %local keyvar /* roll up the md5 */
53
- prevkeyvar /* retain prev record md5 */
54
- lastvar /* last var in input ds */
55
- varlist var i;
56
- /* avoid naming conflict for hash key vars */
57
- %let keyvar=%mf_getuniquename();
58
- %let prevkeyvar=%mf_getuniquename();
59
- %let lastvar=%mf_getuniquename();
60
- %let varlist=%mf_getvarlist(&libds);
61
- data &outds(rename=(&keyvar=hashkey) keep=&keyvar);
62
- length &prevkeyvar &keyvar $32;
63
- retain &prevkeyvar "%sysfunc(md5(%str(&salt)),$hex32.)";
64
- set &libds end=&lastvar;
65
- /* hash should include previous row */
66
- &keyvar=put(md5(&prevkeyvar
67
- /* loop every column, hashing every individual value */
68
- %do i=1 %to %sysfunc(countw(&varlist));
69
- %let var=%scan(&varlist,&i,%str( ));
70
- %if %mf_getvartype(&libds,&var)=C %then %do;
71
- !!put(md5(trim(&var)),$hex32.)
72
- %end;
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
@@ -36,5 +36,5 @@
36
36
  "@sasjs/cli": "3.6.0",
37
37
  "@sasjs/core": "4.4.7"
38
38
  },
39
- "version": "4.18.4"
39
+ "version": "4.18.7"
40
40
  }
@@ -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
- filename &outref temp;
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=&outref
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;
@@ -114,6 +114,7 @@
114
114
  data _null_;
115
115
  set &tempds;
116
116
  if not (upcase(name) =:"DATA"); /* ignore temp datasets */
117
+ if not (upcase(name)=:"_DATA_");
117
118
  i+1;
118
119
  call symputx(cats('wt',i),name,'l');
119
120
  call symputx('wtcnt',i,'l');