<?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: Flagging using prxmatch in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Flagging-using-prxmatch/m-p/318751#M313375</link>
    <description>&lt;P&gt;1) Hash Table&lt;/P&gt;
&lt;P&gt;2)PROC FORMAT&lt;/P&gt;
&lt;P&gt;3) Array:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data x;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;array x{50} $ 40 ('xx' 'yy' .....);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;flag=( name in x);&lt;/P&gt;</description>
    <pubDate>Wed, 14 Dec 2016 04:10:32 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-12-14T04:10:32Z</dc:date>
    <item>
      <title>Flagging using prxmatch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-using-prxmatch/m-p/318743#M313374</link>
      <description>&lt;P&gt;I have a list of opioids that need to flag for. I need to flag for these opioids in the variable called MEDS which is a free form text variable.&lt;/P&gt;&lt;P&gt;There are about 40-50 opioids that I need to flag for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My current solition is to do a simple prxmatch for each of the 40-50 opioids (not very efficient). For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data opioid_analysis;
	set medeval.opioid;

/*Opiod Flagging*/

	if prxmatch("m/Butrans|Codeine|Dalmacol|Demerol\/pethidine|Dilaudid|Dimetapp-C|Dimethane|Duragesic|Hycodan|Hydromorph Contin|Kadian|Lenoltec|Methadone|Methoxacet/oi", MED_REC_PMED1)&amp;gt; 0 then opioid = 1;
	else opioid=0;
run;&lt;/PRE&gt;&lt;P&gt;I'm wondering how others might tackle this problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;None of the opioids have anything really in common in the string name. Is there a better way to ensure that I capture all the opioids? A more efficient way rather than having to spell out all the opioids like this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2016 03:13:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-using-prxmatch/m-p/318743#M313374</guid>
      <dc:creator>confused_saser</dc:creator>
      <dc:date>2016-12-14T03:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging using prxmatch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-using-prxmatch/m-p/318751#M313375</link>
      <description>&lt;P&gt;1) Hash Table&lt;/P&gt;
&lt;P&gt;2)PROC FORMAT&lt;/P&gt;
&lt;P&gt;3) Array:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data x;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;array x{50} $ 40 ('xx' 'yy' .....);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;flag=( name in x);&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2016 04:10:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-using-prxmatch/m-p/318751#M313375</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-12-14T04:10:32Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging using prxmatch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-using-prxmatch/m-p/318938#M313376</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;I think this might be a littel over my head as I don't really understand your answer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone else have any other ideas or can elaborate on the answer a bit so I can understand.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2016 14:23:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-using-prxmatch/m-p/318938#M313376</guid>
      <dc:creator>confused_saser</dc:creator>
      <dc:date>2016-12-14T14:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging using prxmatch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-using-prxmatch/m-p/319003#M313377</link>
      <description>&lt;P&gt;Here's an expansion of what I think &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;'s array suggestion may have been getting at.&lt;/P&gt;
&lt;PRE&gt;data want;
   set medval.opioid;
   array drugs {4} $ 40 _temporary_ ('Butrans' 'Codeine' 'Dalmacol' 'Demerol');
   do i = 1 to dim (drugs);
      opioid = Findw(MED_REC_PMED1,drugs[i],'I')&amp;gt;0;
      if opioid = 1 then leave; /* stops  searching a the first one found*/
   end;
run;&lt;/PRE&gt;
&lt;P&gt;This demonstrates searching for 4 values, to use more the index on the array {4} would have to match the number of drugs searched, and enter each drug inside the () following the pattern. The 40 is to set the length of character values if the maximum length of any name is greater then increase, or reduce as seems likely.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to know which is found you could add:&lt;/P&gt;
&lt;P&gt;(before the Do loop)&lt;/P&gt;
&lt;P&gt;length Found $ 40;&amp;nbsp; Number here should match the array element size.&lt;/P&gt;
&lt;P&gt;Inside the do loop:&lt;/P&gt;
&lt;P&gt;Found = drugs[i];&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2016 17:58:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-using-prxmatch/m-p/319003#M313377</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-12-14T17:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging using prxmatch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-using-prxmatch/m-p/319046#M313378</link>
      <description>&lt;P&gt;thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;! that helps me understand. I'll have to do a bit more research!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2016 20:40:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-using-prxmatch/m-p/319046#M313378</guid>
      <dc:creator>confused_saser</dc:creator>
      <dc:date>2016-12-14T20:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging using prxmatch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-using-prxmatch/m-p/319178#M313379</link>
      <description>&lt;PRE&gt;
If you don't have a big table, you also could try SQL.


data key;
input k $20.;
cards;
Butrans
Codeine
Dalmacol
Demerol
;
run;

data have;
input id $20.;
cards;
BBButrans
Ceine
Dcol
Demerolll
;
run;
proc sql;
select *,case when exists(select * from have,key 
where id=a.id and upcase(id) contains strip(upcase(k))) then 1 
else 0 end as opioid
 from have as a;
quit;

&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Dec 2016 07:17:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-using-prxmatch/m-p/319178#M313379</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-12-15T07:17:17Z</dc:date>
    </item>
  </channel>
</rss>

