<?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: To find if elements under a group are the substring of another string ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/To-find-if-elements-under-a-group-are-the-substring-of-another/m-p/478345#M286329</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Column1 $35.                        group;
cards;
Benefits,verify                      1
claims,verify,benefits,verify        2
inquiry,type                         3
claims,verify                        4
;
run;

proc sql;
create table temp as
 select a.column1,b.group,count(*) as n
  from have as a , have as b
   where upcase(b.column1) contains upcase(strip(a.column1)) and a.group ne b.group
    group by a.column1;
create table want as
select * from temp
union
select column1,0,0 from have where column1 not in (select column1 from temp) ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 16 Jul 2018 12:30:50 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2018-07-16T12:30:50Z</dc:date>
    <item>
      <title>To find if elements under a group are the substring of another string ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-if-elements-under-a-group-are-the-substring-of-another/m-p/478271#M286328</link>
      <description>&lt;P&gt;I want to find if the given elements under a group are the part of another string or no ? If they are then I want the group number of the string where it was the part. They should be&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;part&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;of another string.For example, 'Benefits, verify' is one string under group 1 and that is part of group 2 string (claims,verify,benefits,verify). I also want to count how many times it appears in another string.&lt;/P&gt;&lt;P&gt;For example&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;PRE class="lang-r prettyprint prettyprinted"&gt;&lt;CODE&gt;&lt;SPAN class="pln"&gt;Column1                            group
Benefits&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;verify                      &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;claims&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;verify&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;benefits&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;verify        &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;2&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;inquiry&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;type                         &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;3&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;claims&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;verify                        &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;4&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Output expected:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;PRE class="lang-r prettyprint prettyprinted"&gt;&lt;CODE&gt;&lt;SPAN class="pln"&gt;column1                        Part of group      count
Benefits&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; verify                 &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;2&lt;/SPAN&gt;                  &lt;SPAN class="lit"&gt;1&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;claims&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;verify                    &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;2&lt;/SPAN&gt;                  &lt;SPAN class="lit"&gt;1&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;inquiry&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;type                     &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;-&lt;/SPAN&gt;                  &lt;SPAN class="pun"&gt;-&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;claims&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;verify&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;benefits&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;verify    &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;-&lt;/SPAN&gt;                  &lt;SPAN class="pun"&gt;-&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 16 Jul 2018 04:14:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-if-elements-under-a-group-are-the-substring-of-another/m-p/478271#M286328</guid>
      <dc:creator>vrushankshah</dc:creator>
      <dc:date>2018-07-16T04:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: To find if elements under a group are the substring of another string ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-if-elements-under-a-group-are-the-substring-of-another/m-p/478345#M286329</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Column1 $35.                        group;
cards;
Benefits,verify                      1
claims,verify,benefits,verify        2
inquiry,type                         3
claims,verify                        4
;
run;

proc sql;
create table temp as
 select a.column1,b.group,count(*) as n
  from have as a , have as b
   where upcase(b.column1) contains upcase(strip(a.column1)) and a.group ne b.group
    group by a.column1;
create table want as
select * from temp
union
select column1,0,0 from have where column1 not in (select column1 from temp) ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Jul 2018 12:30:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-if-elements-under-a-group-are-the-substring-of-another/m-p/478345#M286329</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-07-16T12:30:50Z</dc:date>
    </item>
  </channel>
</rss>

