mirror of
https://github.com/sasjs/core.git
synced 2026-07-23 15:35:29 +00:00
chore: updating all.sas
This commit is contained in:
@@ -2621,9 +2621,12 @@ Usage:
|
|||||||
@brief Returns words that are in both string 1 and string 2
|
@brief Returns words that are in both string 1 and string 2
|
||||||
@details Compares two space separated strings and returns the words that are
|
@details Compares two space separated strings and returns the words that are
|
||||||
in both.
|
in both.
|
||||||
|
|
||||||
|
If either string is empty, nothing is returned.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
%put %mf_wordsInStr1andStr2(
|
%put %mf_wordsinstr1andstr2(
|
||||||
Str1=blah sss blaaah brah bram boo
|
Str1=blah sss blaaah brah bram boo
|
||||||
,Str2= blah blaaah brah ssss
|
,Str2= blah blaaah brah ssss
|
||||||
);
|
);
|
||||||
@@ -2641,34 +2644,26 @@ Usage:
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
%macro mf_wordsInStr1andStr2(
|
%macro mf_wordsinstr1andstr2(
|
||||||
Str1= /* string containing words to extract */
|
Str1= /* string containing words to extract */
|
||||||
,Str2= /* used to compare with the extract string */
|
,Str2= /* used to compare with the extract string */
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
%local count_base count_extr i i2 extr_word base_word match outvar;
|
%local count_extr i extr_word outvar;
|
||||||
%if %length(&str1)=0 or %length(&str2)=0 %then %do;
|
%if %length(&str1)=0 or %length(&str2)=0 %then %do;
|
||||||
%put base string (str1)= &str1;
|
%put &sysmacroname: empty input string, nothing to compare;
|
||||||
%put compare string (str2) = &str2;
|
|
||||||
%return;
|
%return;
|
||||||
%end;
|
%end;
|
||||||
%let count_base=%sysfunc(countw(&Str2));
|
|
||||||
%let count_extr=%sysfunc(countw(&Str1));
|
%let count_extr=%sysfunc(countw(&Str1));
|
||||||
|
|
||||||
%do i=1 %to &count_extr;
|
%do i=1 %to &count_extr;
|
||||||
%let extr_word=%scan(&Str1,&i,%str( ));
|
%let extr_word=%scan(&Str1,&i,%str( ));
|
||||||
%let match=0;
|
%if %sysfunc(indexw(%superq(str2),%superq(extr_word)))>0 %then
|
||||||
%do i2=1 %to &count_base;
|
%let outvar=&outvar &extr_word;
|
||||||
%let base_word=%scan(&Str2,&i2,%str( ));
|
|
||||||
%if &extr_word=&base_word %then %let match=1;
|
|
||||||
%end;
|
|
||||||
%if &match=1 %then %let outvar=&outvar &extr_word;
|
|
||||||
%end;
|
%end;
|
||||||
|
/* send out the result without any surrounding whitespace */
|
||||||
&outvar
|
%do;&outvar%end;
|
||||||
|
%mend mf_wordsinstr1andstr2;
|
||||||
%mend mf_wordsInStr1andStr2;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@file
|
@file
|
||||||
@brief Returns words that are in string 1 but not in string 2
|
@brief Returns words that are in string 1 but not in string 2
|
||||||
@@ -2677,9 +2672,12 @@ Usage:
|
|||||||
|
|
||||||
Note - case sensitive!
|
Note - case sensitive!
|
||||||
|
|
||||||
|
If str1 is empty, nothing is returned. If str2 is empty, all the words in
|
||||||
|
str1 are returned.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
%let x= %mf_wordsInStr1ButNotStr2(
|
%let x= %mf_wordsinstr1butnotstr2(
|
||||||
Str1=blah sss blaaah brah bram boo
|
Str1=blah sss blaaah brah bram boo
|
||||||
,Str2= blah blaaah brah ssss
|
,Str2= blah blaaah brah ssss
|
||||||
);
|
);
|
||||||
@@ -2695,34 +2693,26 @@ Usage:
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
%macro mf_wordsInStr1ButNotStr2(
|
%macro mf_wordsinstr1butnotstr2(
|
||||||
Str1= /* string containing words to extract */
|
Str1= /* string containing words to extract */
|
||||||
,Str2= /* used to compare with the extract string */
|
,Str2= /* used to compare with the extract string */
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
%local count_base count_extr i i2 extr_word base_word match outvar;
|
%local count_extr i extr_word outvar;
|
||||||
%if %length(&str1)=0 or %length(&str2)=0 %then %do;
|
%if %length(&str1)=0 %then %do;
|
||||||
%put base string (str1)= &str1;
|
%put &sysmacroname: str1 is empty, nothing to compare;
|
||||||
%put compare string (str2) = &str2;
|
|
||||||
%return;
|
%return;
|
||||||
%end;
|
%end;
|
||||||
%let count_base=%sysfunc(countw(&Str2));
|
|
||||||
%let count_extr=%sysfunc(countw(&Str1));
|
%let count_extr=%sysfunc(countw(&Str1));
|
||||||
|
|
||||||
%do i=1 %to &count_extr;
|
%do i=1 %to &count_extr;
|
||||||
%let extr_word=%scan(&Str1,&i,%str( ));
|
%let extr_word=%scan(&Str1,&i,%str( ));
|
||||||
%let match=0;
|
%if %sysfunc(indexw(%superq(str2),%superq(extr_word)))=0 %then
|
||||||
%do i2=1 %to &count_base;
|
%let outvar=&outvar &extr_word;
|
||||||
%let base_word=%scan(&Str2,&i2,%str( ));
|
|
||||||
%if &extr_word=&base_word %then %let match=1;
|
|
||||||
%end;
|
|
||||||
%if &match=0 %then %let outvar=&outvar &extr_word;
|
|
||||||
%end;
|
%end;
|
||||||
|
/* send out the result without any surrounding whitespace */
|
||||||
&outvar
|
%do;&outvar%end;
|
||||||
|
%mend mf_wordsinstr1butnotstr2;
|
||||||
%mend mf_wordsInStr1ButNotStr2;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@file
|
@file
|
||||||
@brief Creates a text file using pure macro
|
@brief Creates a text file using pure macro
|
||||||
@@ -12372,12 +12362,10 @@ run;
|
|||||||
/*
|
/*
|
||||||
multiply-by-one for consistent cross-system precision.
|
multiply-by-one for consistent cross-system precision.
|
||||||
Ignore null to protect SAS special missing values.
|
Ignore null to protect SAS special missing values.
|
||||||
|
Cannot use IFN() as it evaluates both sides
|
||||||
*/
|
*/
|
||||||
&normal = ifn(
|
if missing(&nums[&i]) then &normal = &nums[&i];
|
||||||
missing(&nums[&i]),
|
else &normal = &nums[&i] * 1;
|
||||||
&nums[&i],
|
|
||||||
&nums[&i] * 1
|
|
||||||
);
|
|
||||||
&numtext = put(&normal, binary64.);
|
&numtext = put(&normal, binary64.);
|
||||||
&digest = md5(trim(&numtext));
|
&digest = md5(trim(&numtext));
|
||||||
substr(&pair, 1, 16) = &state;
|
substr(&pair, 1, 16) = &state;
|
||||||
|
|||||||
Reference in New Issue
Block a user