@sasjs/core 4.68.0 → 4.68.1

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.
@@ -3,9 +3,12 @@
3
3
  @brief Returns words that are in both string 1 and string 2
4
4
  @details Compares two space separated strings and returns the words that are
5
5
  in both.
6
+
7
+ If either string is empty, nothing is returned.
8
+
6
9
  Usage:
7
10
 
8
- %put %mf_wordsInStr1andStr2(
11
+ %put %mf_wordsinstr1andstr2(
9
12
  Str1=blah sss blaaah brah bram boo
10
13
  ,Str2= blah blaaah brah ssss
11
14
  );
@@ -23,31 +26,23 @@
23
26
 
24
27
  **/
25
28
 
26
- %macro mf_wordsInStr1andStr2(
29
+ %macro mf_wordsinstr1andstr2(
27
30
  Str1= /* string containing words to extract */
28
31
  ,Str2= /* used to compare with the extract string */
29
32
  )/*/STORE SOURCE*/;
30
33
 
31
- %local count_base count_extr i i2 extr_word base_word match outvar;
34
+ %local count_extr i extr_word outvar;
32
35
  %if %length(&str1)=0 or %length(&str2)=0 %then %do;
33
- %put base string (str1)= &str1;
34
- %put compare string (str2) = &str2;
36
+ %put &sysmacroname: empty input string, nothing to compare;
35
37
  %return;
36
38
  %end;
37
- %let count_base=%sysfunc(countw(&Str2));
38
39
  %let count_extr=%sysfunc(countw(&Str1));
39
40
 
40
41
  %do i=1 %to &count_extr;
41
42
  %let extr_word=%scan(&Str1,&i,%str( ));
42
- %let match=0;
43
- %do i2=1 %to &count_base;
44
- %let base_word=%scan(&Str2,&i2,%str( ));
45
- %if &extr_word=&base_word %then %let match=1;
46
- %end;
47
- %if &match=1 %then %let outvar=&outvar &extr_word;
43
+ %if %sysfunc(indexw(%superq(str2),%superq(extr_word)))>0 %then
44
+ %let outvar=&outvar &extr_word;
48
45
  %end;
49
-
50
- &outvar
51
-
52
- %mend mf_wordsInStr1andStr2;
53
-
46
+ /* send out the result without any surrounding whitespace */
47
+ %do;&outvar%end;
48
+ %mend mf_wordsinstr1andstr2;
@@ -6,9 +6,12 @@
6
6
 
7
7
  Note - case sensitive!
8
8
 
9
+ If str1 is empty, nothing is returned. If str2 is empty, all the words in
10
+ str1 are returned.
11
+
9
12
  Usage:
10
13
 
11
- %let x= %mf_wordsInStr1ButNotStr2(
14
+ %let x= %mf_wordsinstr1butnotstr2(
12
15
  Str1=blah sss blaaah brah bram boo
13
16
  ,Str2= blah blaaah brah ssss
14
17
  );
@@ -24,31 +27,23 @@
24
27
 
25
28
  **/
26
29
 
27
- %macro mf_wordsInStr1ButNotStr2(
30
+ %macro mf_wordsinstr1butnotstr2(
28
31
  Str1= /* string containing words to extract */
29
32
  ,Str2= /* used to compare with the extract string */
30
33
  )/*/STORE SOURCE*/;
31
34
 
32
- %local count_base count_extr i i2 extr_word base_word match outvar;
33
- %if %length(&str1)=0 or %length(&str2)=0 %then %do;
34
- %put base string (str1)= &str1;
35
- %put compare string (str2) = &str2;
35
+ %local count_extr i extr_word outvar;
36
+ %if %length(&str1)=0 %then %do;
37
+ %put &sysmacroname: str1 is empty, nothing to compare;
36
38
  %return;
37
39
  %end;
38
- %let count_base=%sysfunc(countw(&Str2));
39
40
  %let count_extr=%sysfunc(countw(&Str1));
40
41
 
41
42
  %do i=1 %to &count_extr;
42
43
  %let extr_word=%scan(&Str1,&i,%str( ));
43
- %let match=0;
44
- %do i2=1 %to &count_base;
45
- %let base_word=%scan(&Str2,&i2,%str( ));
46
- %if &extr_word=&base_word %then %let match=1;
47
- %end;
48
- %if &match=0 %then %let outvar=&outvar &extr_word;
44
+ %if %sysfunc(indexw(%superq(str2),%superq(extr_word)))=0 %then
45
+ %let outvar=&outvar &extr_word;
49
46
  %end;
50
-
51
- &outvar
52
-
53
- %mend mf_wordsInStr1ButNotStr2;
54
-
47
+ /* send out the result without any surrounding whitespace */
48
+ %do;&outvar%end;
49
+ %mend mf_wordsinstr1butnotstr2;
package/package.json CHANGED
@@ -35,5 +35,5 @@
35
35
  "maintainers": [
36
36
  "https://sasapps.io"
37
37
  ],
38
- "version": "4.68.0"
38
+ "version": "4.68.1"
39
39
  }