<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Check whether a dataset variable value contains any string from a list in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602912#M174615</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/297580"&gt;@aljones1816&lt;/a&gt;&amp;nbsp; &amp;nbsp;An improvement to the Proc SQL to meet your requirement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want(drop=m) as
select a.*,b.*,monotonic() as m
from one a left join two b
on findw(id_field,strip(id))&amp;gt;0
group by id_field
having max(m)=m;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 08 Nov 2019 22:13:25 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-11-08T22:13:25Z</dc:date>
    <item>
      <title>Check whether a dataset variable value contains any string from a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602871#M174601</link>
      <description>&lt;P&gt;I have a dataset containing a field of codes. Sometimes, the field contains multiple codes in a single row separated by a comma. the variable looks something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id_field:&lt;/P&gt;&lt;P&gt;a23g22,hh998&lt;/P&gt;&lt;P&gt;bg884&lt;/P&gt;&lt;P&gt;g9932&lt;/P&gt;&lt;P&gt;gh994,f99g,4jgkf,fgldf&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a second dataset containing a list of IDs without any multiples on the same row, like this:&lt;/P&gt;&lt;P&gt;id:&lt;/P&gt;&lt;P&gt;bg884&lt;/P&gt;&lt;P&gt;g9932&lt;/P&gt;&lt;P&gt;gh994&lt;/P&gt;&lt;P&gt;f99g&lt;/P&gt;&lt;P&gt;4jgkf&lt;/P&gt;&lt;P&gt;fgldf&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I need to do is to check for each row in the first dataset whether the variable contains the string on any row of the second dataset's ID variable, then perform some action if there is a match. So for instance, row 4 in the first dataset contains strings matching rows 3-6 of the second. I could just merge the two lists together, except for the fact that dataset one has many cells with multiple values, so they wouldn't join.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My intuition was that I could pull the ids from the second dataset into a list:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select distinct id into :id_list separated by ','&lt;BR /&gt;from all_ids;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then perhaps perform a do loop to iterate through each value of the list using the "find" function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; for each value in id_list do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if find(id_field,'id_list value') then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; code here that does stuff;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I do not know how to structure the syntax to achieve this, or if this is even the ideal solution (both datasets are small so I am not worried about processing time).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2019 20:52:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602871#M174601</guid>
      <dc:creator>aljones1816</dc:creator>
      <dc:date>2019-11-08T20:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: Check whether a dataset variable value contains any string from a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602875#M174602</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input id_field $35.;
cards;
a23g22,hh998
bg884
g9932
gh994,f99g,4jgkf,fgldf
;
data two;
input id $;
cards;
bg884
g9932
gh994
f99g
4jgkf
;
/*Only matches*/
proc sql;
create table want as
select a.*,b.*
from one a inner join two b
on findw(id_field,strip(id))&amp;gt;0;
quit;
/*Both matches and Non matches*/
proc sql;
create table want as
select a.*,b.*
from one a left join two b
on findw(id_field,strip(id))&amp;gt;0;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Nov 2019 21:01:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602875#M174602</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-08T21:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: Check whether a dataset variable value contains any string from a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602877#M174603</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input id_field $35.;
cards;
a23g22,hh998
bg884
g9932
gh994,f99g,4jgkf,fgldf
;
data two;
input id $;
cards;
bg884
g9932
gh994
f99g
4jgkf
;
data want;
if _n_=1 then do;
 if 0 then set two;
   dcl hash H (dataset:'two') ;
   h.definekey  ("id") ;
   h.definedata ("id") ;
   h.definedone () ;
   dcl hiter hi('h');
 end;
set one;
do while(hi.next()=0);
  if findw(id_field,strip(id))&amp;gt;0 then output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Nov 2019 21:07:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602877#M174603</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-08T21:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: Check whether a dataset variable value contains any string from a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602883#M174605</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;Thanks so much for your help! One issue I have with the left join solution is that my output "want" dataset contains more rows than the input "have" dataset. I think this is because in the rows in the "have" with multiple IDs, there are multiple matches with the second id list. Can you tell me how I can match only once?&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2019 21:25:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602883#M174605</guid>
      <dc:creator>aljones1816</dc:creator>
      <dc:date>2019-11-08T21:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: Check whether a dataset variable value contains any string from a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602884#M174606</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/297580"&gt;@aljones1816&lt;/a&gt;&amp;nbsp; &amp;nbsp;Can you plz post your expected solution or in other words the expected output for the input sample, so we can avoid assumptions&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2019 21:26:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602884#M174606</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-08T21:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: Check whether a dataset variable value contains any string from a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602889#M174608</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;I will try. I am new at this so please excuse my poor formatting.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the "have" dataset, I only want to know if a given row matches one of the ids from dataset two. So I would want the putput to be something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id_field:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;id&lt;/P&gt;&lt;P&gt;a23g22,hh998&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;bg884&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;bg884&lt;/P&gt;&lt;P&gt;g9932&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;g9932&lt;/P&gt;&lt;P&gt;gh994,f99g,4jgkf,fgldf&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;gh994&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not want, for example, the last row to duplicate for every match, like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id_field:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;id&lt;/P&gt;&lt;P&gt;a23g22,hh998&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;bg884&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;bg884&lt;/P&gt;&lt;P&gt;g9932&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;g9932&lt;/P&gt;&lt;P&gt;gh994,f99g,4jgkf,fgldf&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;gh994&lt;/P&gt;&lt;P&gt;gh994,f99g,4jgkf,fgldf&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; f99g&lt;/P&gt;&lt;P&gt;gh994,f99g,4jgkf,fgldf&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4jgkf&lt;/P&gt;&lt;P&gt;gh994,f99g,4jgkf,fgldf&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fgldf&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2019 21:32:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602889#M174608</guid>
      <dc:creator>aljones1816</dc:creator>
      <dc:date>2019-11-08T21:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: Check whether a dataset variable value contains any string from a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602896#M174609</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input id_field $35.;
cards;
a23g22,hh998
bg884
g9932
gh994,f99g,4jgkf,fgldf
;
run;
data two;
input id $;
cards;
bg884
g9932
gh994
f99g
4jgkf
;
run;

data want;
if _n_=0 then set one;
	if _n_ =1 then
		do;
			declare hash h(dataset:'one');
			declare hiter iter('h');
			h.definekey('id_field');
			h.definedata(all:'y');
			h.definedone();
		end;
	set two;
	rc=iter.first();



	do while(rc eq 0);
		if find(id_field,id,'t') &amp;gt; 0  then output;
		
		rc=iter.next();
	end;

	keep id;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Nov 2019 21:38:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602896#M174609</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2019-11-08T21:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: Check whether a dataset variable value contains any string from a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602902#M174612</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223452"&gt;@r_behata&lt;/a&gt;&amp;nbsp;Thanks so much for this solution! One thing I need in the output though is that a raw in the "have" dataset only matches once with a row in the id dataset, so that the output "want" doesn't have more rows than the input. Something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id_field:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;id&lt;/P&gt;&lt;P&gt;a23g22,hh998&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;bg884&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;bg884&lt;/P&gt;&lt;P&gt;g9932&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;g9932&lt;/P&gt;&lt;P&gt;gh994,f99g,4jgkf,fgldf&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;gh994&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead of this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id_field:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;id&lt;/P&gt;&lt;P&gt;a23g22,hh998&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;bg884&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;bg884&lt;/P&gt;&lt;P&gt;g9932&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;g9932&lt;/P&gt;&lt;P&gt;gh994,f99g,4jgkf,fgldf&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;gh994&lt;/P&gt;&lt;P&gt;gh994,f99g,4jgkf,fgldf&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; f99g&lt;/P&gt;&lt;P&gt;gh994,f99g,4jgkf,fgldf&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4jgkf&lt;/P&gt;&lt;P&gt;gh994,f99g,4jgkf,fgldf&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fgldf&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you help me understand how to achieve that outcome?&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2019 21:48:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602902#M174612</guid>
      <dc:creator>aljones1816</dc:creator>
      <dc:date>2019-11-08T21:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Check whether a dataset variable value contains any string from a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602909#M174614</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/297580"&gt;@aljones1816&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Keep a Match flag*/
data want;
if _n_=1 then do;
 if 0 then set two;
   dcl hash H (dataset:'two') ;
   h.definekey  ("id") ;
   h.definedata ("id") ;
   h.definedone () ;
   dcl hiter hi('h');
 end;
set one;
match=0;
do while(hi.next()=0);
 if findw(id_field,strip(id))&amp;gt;0 then match=1;
end;
if not match then call missing(id);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Nov 2019 22:01:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602909#M174614</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-08T22:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: Check whether a dataset variable value contains any string from a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602912#M174615</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/297580"&gt;@aljones1816&lt;/a&gt;&amp;nbsp; &amp;nbsp;An improvement to the Proc SQL to meet your requirement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want(drop=m) as
select a.*,b.*,monotonic() as m
from one a left join two b
on findw(id_field,strip(id))&amp;gt;0
group by id_field
having max(m)=m;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Nov 2019 22:13:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602912#M174615</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-08T22:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: Check whether a dataset variable value contains any string from a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602918#M174617</link>
      <description>&lt;P&gt;Okay&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/297580"&gt;@aljones1816&lt;/a&gt;&amp;nbsp; &amp;nbsp;One linear simple and safe method,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
if _n_=1 then do;
 if 0 then set two;
   dcl hash H (dataset:'two') ;
   h.definekey  ("id") ;
   h.definedata ("id") ;
   h.definedone () ;
 end;
set one;
call missing(id);
do _n_=1 to countw(id_field,',');
 if h.find(key:scan(id_field,_n_,','))=0 then leave;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Nov 2019 22:19:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602918#M174617</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-08T22:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: Check whether a dataset variable value contains any string from a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602958#M174634</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/297580"&gt;@aljones1816&lt;/a&gt;;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;For each record in ONE, loop through the list of the comma-delimited IDs.&lt;/LI&gt;
&lt;LI&gt;If any ID is in TWO, break the loop, and the ID on which the loop has stopped is your guy.&lt;/LI&gt;
&lt;LI&gt;Otherwise the ID value stopping the loop will be missing, which is what you need.&amp;nbsp;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;In other (SAS) words:&lt;/P&gt;
&lt;PRE&gt;data one ;                                                                                                                                                                                                                                                      
  input id_field $35. ;                                                                                                                                                                                                                                         
  cards ;                                                                                                                                                                                                                                                       
a23g22,hh998                                                                                                                                                                                                                                                    
bg884                                                                                                                                                                                                                                                           
not,in,two                                                                                                                                                                                                                                                      
g9932                                                                                                                                                                                                                                                           
gh994,f99g,4jgkf,fgldf                                                                                                                                                                                                                                          
;                                                                                                                                                                                                                                                               
run ;                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                
data two ;                                                                                                                                                                                                                                                      
  input id $ ;                                                                                                                                                                                                                                                  
  cards ;                                                                                                                                                                                                                                                       
bg884                                                                                                                                                                                                                                                           
g9932                                                                                                                                                                                                                                                           
gh994                                                                                                                                                                                                                                                           
f99g                                                                                                                                                                                                                                                            
4jgkf                                                                                                                                                                                                                                                           
;                                                                                                                                                                                                                                                               
run ;                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                
data want ;                                                                                                                                                                                                                                                     
  if _n_ = 1 then do ;                                                                                                                                                                                                                                          
    dcl hash h (dataset:"two") ;                                                                                                                                                                                                                                
    h.definekey ("id") ;                                                                                                                                                                                                                                        
    h.definedone () ;                                                                                                                                                                                                                                           
  end ;                                                                                                                                                                                                                                                         
  set one two (obs=0) ;                                                                                                                                                                                                                                         
  do _n_ = 1 by 1 until (h.check() = 0 or cmiss (id)) ;                                                                                                                                                                                                         
    id = scan (id_field, _n_) ;                                                                                                                                                                                                                                 
  end ;                                                                                                                                                                                                                                                         
run ;                     
&lt;/PRE&gt;
&lt;P&gt;By the nature of the algorithm, the number of output rows will equal that in the input.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;</description>
      <pubDate>Sat, 09 Nov 2019 04:07:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-whether-a-dataset-variable-value-contains-any-string-from/m-p/602958#M174634</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-11-09T04:07:36Z</dc:date>
    </item>
  </channel>
</rss>

