<?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: Find observations that contain one word but NOT another in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-observations-that-contain-one-word-but-NOT-another/m-p/730108#M227308</link>
    <description>Awesome, thank you.</description>
    <pubDate>Tue, 30 Mar 2021 14:59:25 GMT</pubDate>
    <dc:creator>shughe5</dc:creator>
    <dc:date>2021-03-30T14:59:25Z</dc:date>
    <item>
      <title>Find observations that contain one word but NOT another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-observations-that-contain-one-word-but-NOT-another/m-p/730106#M227306</link>
      <description>&lt;P&gt;I am trying to find observations that contain one word in a string but NOT another.&lt;/P&gt;&lt;P&gt;For example, my observations look something like this:&lt;/P&gt;&lt;P&gt;Diabetes mellitus&lt;/P&gt;&lt;P&gt;Screening for diabetes mellitus&lt;/P&gt;&lt;P&gt;Type II diabetes&amp;nbsp;&lt;/P&gt;&lt;P&gt;History of diabetes&lt;/P&gt;&lt;P&gt;Family history of type II diabetes&lt;/P&gt;&lt;P&gt;Encounter for screening of diabetes mellitus&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to return observations that contain 'diabetes' or 'Diabetes' but NOT 'Screening' 'screening' 'History' 'history'&lt;/P&gt;&lt;P&gt;I tried what I thought the most intuitive way to do this would be:&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;&lt;STRONG&gt;freq&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;data&lt;/SPAN&gt;=data;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s2"&gt;tables&lt;/SPAN&gt;&amp;nbsp;diagnosis;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s2"&gt;where&lt;/SPAN&gt; find(diagnosis, &lt;SPAN class="s3"&gt;'diabetes'&lt;/SPAN&gt;) or find(diagnosis, &lt;SPAN class="s3"&gt;'Diabetes'&lt;/SPAN&gt;) and not find(diagnosis, &lt;SPAN class="s3"&gt;'History'&lt;/SPAN&gt;) or find(diagnosis, &lt;SPAN class="s3"&gt;'screening'&lt;/SPAN&gt;);&lt;/P&gt;&lt;P class="p2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN class="s4"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;but obviously, this did not work and returned observations that DO contain History and Screening, ignoring the 'not.' Is the find function the best way to do this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Mar 2021 14:41:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-observations-that-contain-one-word-but-NOT-another/m-p/730106#M227306</guid>
      <dc:creator>shughe5</dc:creator>
      <dc:date>2021-03-30T14:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: Find observations that contain one word but NOT another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-observations-that-contain-one-word-but-NOT-another/m-p/730107#M227307</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    if find(diagnosis,'diabetes','i')&amp;gt;0 and find(diagnosis,'history','i')=0 and find(diagnosis,'screening','i')=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Mar 2021 14:53:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-observations-that-contain-one-word-but-NOT-another/m-p/730107#M227307</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-03-30T14:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: Find observations that contain one word but NOT another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-observations-that-contain-one-word-but-NOT-another/m-p/730108#M227308</link>
      <description>Awesome, thank you.</description>
      <pubDate>Tue, 30 Mar 2021 14:59:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-observations-that-contain-one-word-but-NOT-another/m-p/730108#M227308</guid>
      <dc:creator>shughe5</dc:creator>
      <dc:date>2021-03-30T14:59:25Z</dc:date>
    </item>
  </channel>
</rss>

