<?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: SAS Hash Macro to exclude records with certain words in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Macro-to-exclude-records-with-certain-words/m-p/308492#M66213</link>
    <description>&lt;P&gt;You would think! But unfortunately it doesn't probably because x_drug_name may look something like this: acetaminophen/aspirin/caffeine 250 mg-520 mg-32.5&lt;/P&gt;</description>
    <pubDate>Tue, 01 Nov 2016 13:16:45 GMT</pubDate>
    <dc:creator>SASsy05</dc:creator>
    <dc:date>2016-11-01T13:16:45Z</dc:date>
    <item>
      <title>SAS Hash Macro to exclude records with certain words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Macro-to-exclude-records-with-certain-words/m-p/308348#M66163</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to write a hash macro in SAS 9.4 that will text match medication names in a dataset to a list of terms in another dataset. I want it to output if there is a text match but only if it doesn't include certain terms. This is what I have (taken out of the macro to see if I could get it to work). It works if I don't include the exclusion term (s).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; data step2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; length drug_name $ 100;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; length x_drug_name $ 50;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; declare Hash Drug ();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc = Drug.DefineKey ('drug_name');&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc = Drug.DefineData ("drug_cid");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc = Drug.DefineDone ();&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do until (eof1) ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set Med_Aspirin end = eof1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc = Drug.add ();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call missing(drug_name); /* initialize the variable we intend to fill */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call missing(drug_cid); /* initialize the variable we intend to fill */&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do until (eof2) ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sample end = eof2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where&amp;nbsp; drug_concept_id=0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i = 1 to 5;&amp;nbsp; *cycle thru the text elements (up to 5) of x_drug_name looking for a match with a name on the name list;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; drug_name=scan(upcase(x_drug_name),i,' -/!*#\,');&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc = Drug.find ();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if rc=0 then output;&amp;nbsp; * this is where I was hoping to say if rc=0 and upcase(x_drug_name) ne caffeine anywhere in the field, then output;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; keep drug_exposure_id&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;drug_exposure_start_date&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; x_drug_name&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; drug_name&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; drug_concept_id&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; drug_cid;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; stop;&lt;BR /&gt;&amp;nbsp; run;&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;&lt;P&gt;Thank you for any help and suggestions you may have!&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 18:44:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Macro-to-exclude-records-with-certain-words/m-p/308348#M66163</guid>
      <dc:creator>SASsy05</dc:creator>
      <dc:date>2016-10-31T18:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Hash Macro to exclude records with certain words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Macro-to-exclude-records-with-certain-words/m-p/308468#M66203</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Haven't got into details but shouldn't it be&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;...and upcase(x_drug_name) ne "CAFFEINE"&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Nov 2016 10:14:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Macro-to-exclude-records-with-certain-words/m-p/308468#M66203</guid>
      <dc:creator>PeterKellberg</dc:creator>
      <dc:date>2016-11-01T10:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Hash Macro to exclude records with certain words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Macro-to-exclude-records-with-certain-words/m-p/308485#M66207</link>
      <description>&lt;P&gt;Could you provide some sample data?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 12:26:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Macro-to-exclude-records-with-certain-words/m-p/308485#M66207</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2016-11-01T12:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Hash Macro to exclude records with certain words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Macro-to-exclude-records-with-certain-words/m-p/308492#M66213</link>
      <description>&lt;P&gt;You would think! But unfortunately it doesn't probably because x_drug_name may look something like this: acetaminophen/aspirin/caffeine 250 mg-520 mg-32.5&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 13:16:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Macro-to-exclude-records-with-certain-words/m-p/308492#M66213</guid>
      <dc:creator>SASsy05</dc:creator>
      <dc:date>2016-11-01T13:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Hash Macro to exclude records with certain words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Macro-to-exclude-records-with-certain-words/m-p/308493#M66214</link>
      <description>&lt;P&gt;x_drug_name&lt;/P&gt;&lt;P&gt;acetaminophen/aspirin/caffeine 250 mg-520 mg-32.5&lt;/P&gt;&lt;P&gt;aspirin-acetaminophen-caffeine (EXCEDRIN MIGRAINE)&lt;/P&gt;&lt;P&gt;aspirin 81 mg oral enteric coated capsule&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At some point I am going to need to exclude a record if it contains many different terms, not just caffeine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 13:18:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Macro-to-exclude-records-with-certain-words/m-p/308493#M66214</guid>
      <dc:creator>SASsy05</dc:creator>
      <dc:date>2016-11-01T13:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Hash Macro to exclude records with certain words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Macro-to-exclude-records-with-certain-words/m-p/308506#M66215</link>
      <description>&lt;P&gt;Try using FIND() function instead of SCAN()&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 14:15:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Macro-to-exclude-records-with-certain-words/m-p/308506#M66215</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2016-11-01T14:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Hash Macro to exclude records with certain words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Macro-to-exclude-records-with-certain-words/m-p/308516#M66220</link>
      <description>&lt;P&gt;ah ok well this could do it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;...and find(x_drug_name,"caffeine","i")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The "i" modifier for the FIND functions will make the search case insensitive&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 14:34:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Macro-to-exclude-records-with-certain-words/m-p/308516#M66220</guid>
      <dc:creator>PeterKellberg</dc:creator>
      <dc:date>2016-11-01T14:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Hash Macro to exclude records with certain words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Macro-to-exclude-records-with-certain-words/m-p/308517#M66221</link>
      <description>&lt;P&gt;You may well want to consider instead of&lt;/P&gt;
&lt;P&gt;&amp;nbsp;do i = 1 to 5;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;which may have issues with single words and will fail if the word you look for is in a string with more than 5 words to use&lt;/P&gt;
&lt;P&gt;do i = 1 to Countw(text);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If using Scan then you also want to make sure that Countw and Scan use the same definition of word delimiter.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 14:36:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Macro-to-exclude-records-with-certain-words/m-p/308517#M66221</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-11-01T14:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Hash Macro to exclude records with certain words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Macro-to-exclude-records-with-certain-words/m-p/308519#M66222</link>
      <description>&lt;P&gt;Exactly What I mean to say.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 14:40:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Macro-to-exclude-records-with-certain-words/m-p/308519#M66222</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2016-11-01T14:40:03Z</dc:date>
    </item>
  </channel>
</rss>

