@sasjs/core 3.0.3 → 3.1.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.
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@file
|
|
3
|
+
@brief Returns words that are in both string 1 and string 2
|
|
4
|
+
@details Compares two space separated strings and returns the words that are
|
|
5
|
+
in both.
|
|
6
|
+
Usage:
|
|
7
|
+
|
|
8
|
+
%put %mf_wordsInStr1andStr2(
|
|
9
|
+
Str1=blah sss blaaah brah bram boo
|
|
10
|
+
,Str2= blah blaaah brah ssss
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
returns:
|
|
14
|
+
> blah blaaah brah
|
|
15
|
+
|
|
16
|
+
@param str1= string containing words to extract
|
|
17
|
+
@param str2= used to compare with the extract string
|
|
18
|
+
|
|
19
|
+
@warning CASE SENSITIVE!
|
|
20
|
+
|
|
21
|
+
@version 9.2
|
|
22
|
+
@author Allan Bowe
|
|
23
|
+
|
|
24
|
+
**/
|
|
25
|
+
|
|
26
|
+
%macro mf_wordsInStr1andStr2(
|
|
27
|
+
Str1= /* string containing words to extract */
|
|
28
|
+
,Str2= /* used to compare with the extract string */
|
|
29
|
+
)/*/STORE SOURCE*/;
|
|
30
|
+
|
|
31
|
+
%local count_base count_extr i i2 extr_word base_word match outvar;
|
|
32
|
+
%if %length(&str1)=0 or %length(&str2)=0 %then %do;
|
|
33
|
+
%put %str(WARN)ING: empty string provided!;
|
|
34
|
+
%put base string (str1)= &str1;
|
|
35
|
+
%put compare string (str2) = &str2;
|
|
36
|
+
%return;
|
|
37
|
+
%end;
|
|
38
|
+
%let count_base=%sysfunc(countw(&Str2));
|
|
39
|
+
%let count_extr=%sysfunc(countw(&Str1));
|
|
40
|
+
|
|
41
|
+
%do i=1 %to &count_extr;
|
|
42
|
+
%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=1 %then %let outvar=&outvar &extr_word;
|
|
49
|
+
%end;
|
|
50
|
+
|
|
51
|
+
&outvar
|
|
52
|
+
|
|
53
|
+
%mend mf_wordsInStr1andStr2;
|
|
54
|
+
|
package/package.json
CHANGED